Resetting MySQL root password

Somehow I got banned from own MySQL server installed on my Mac running OSX Moutain Lion. Every time I tried to log in as root (my only user) I would get: mysql access denied for user ”@’localhost’

Don’t know how I ended up in that situation, but write here how I got out, for others to know (and for me to remember). The deal is basically to reset the root password.

The solution is in this blog post: http://innovativethought.net/2007/05/17/resetting-your-forgotten-mysql-password/

Here are the step I followed with MySQL 5.5.28 running on OSX 10.8.3:

  • turn off mysql server
  • first terminal: sudo /usr/local/mysql/bin/mysqld_safe –skip-grant-tables
  • second terminal:
    launch the admin console: /usr/local/mysql/bin/mysql mysql
    reset the password: UPDATE mysql.user SET Password=PASSWORD(“newpwd”) WHERE User=”root”; FLUSH PRIVILEGES;
  • turn on mysql server

EDIT : got stuck a couple of days later with the same problem and the same solution did not work. I used the little scripts provided there: http://code.macminivault.com/

2 thoughts on “Resetting MySQL root password

  1. I read your edit

    EDIT : got stuck a couple of days later with the same problem and the same solution did not work. I used the little scripts provided there: http://code.macminivault.com/

    The way I found around this was to go into the phpmyadmin/config.inc.php

    and change

    $cfg[‘Servers’][$i][‘host’] = ‘localhost’;

    to:

    $cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1’;

    as soon as I did that I was logged right in

Leave a Reply

Your email address will not be published. Required fields are marked *