How to Reset the ROOT Password for MySQL on Mac OS 10.10

This post explains how to reset the MySQL root user on a Mac running OS 10.10. This procedure is for the case that you are unable to log in as the root user and need to reset the root user’s password.

Note that there are 2 colored sets of examples. One is for MySQL installed by Brew.

1) Stop the MySQL server

$> sudo mysql.server stop

2) Start the server in safe mode and bypass privilege tables.

$> sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
$> sudo /usr/local/Cellar/mysql/5.7.10/bin/mysqld_safe --skip-grant-tables

3) In a seperate terminal window start MySQL.

$> sudo /usr/local/mysql/bin/mysql -u root
$> /usr/local/Cellar/mysql/5.7.10/bin/mysql -u root

4) Perform the MySQL root user password reset query and flush the the privileges.

mysql> UPDATE mysql.user SET authentication_string=PASSWORD("Z9(quinine)") WHERE User='root';

NOTE: For versions of prior to MySQL 5.7, replace the ‘authentication_string’ portion of the above query with ‘password’.

Leave a Reply

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