Reset Initial MySQL Root Password on OS X

Reset the initial MySQL root password  on OS X if you are getting the following error:

You must reset your password using ALTER USER statement before executing this statement.

Here is how to update the mysql user password on osx, in sandbox mode:

mysql -u <user> -p --connect-expired-password

Then set the password for MySQL 5.7+:

SET PASSWORD FOR 'root'@'localhost' = ('mypassword');

For older MySQL, use the following command:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypassword');

This has been tested on El Capitan.

Leave a Reply

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