Reset MySQL Password on OS X Lion

In case you forgot or didn’t set the password for “root,” do the following:

1. Create a file called mysql-init with the following entries (I placed mine in my home directory):

UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass’) WHERE User=’root’;
FLUSH PRIVILEGES;
2. Make sure mysqld is not running (i.e. terminal > ps -ef | grep mysql)

3. Run mysql with the following command:

mysqld_safe –init-file=/home/me/mysql-init &

4. Try logging in with root: mysql -u root -p

5. You can now delete mysql-init and start mysql in the normal way: mysql.server start

Note: I tried mysqld –skip-grant-tables, but it didn’t work for me.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.