How to Change the MySQL root Password on Mac OS
Step 1: Stop MySQL service: Typically this can be done from ‘System Preferences
‘ > MySQL
> ‘Stop MySQL Server
‘
Step 2: Skipping Access Tables: Run the server in safe mode
with privilege bypass.If you have installed MySQL5, fire up the Terminal window and execute
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables
For older versions of MySQL, execute the following command
/usr/local/mysql/bin/safe_mysqld --skip-grant-tables
Step 3: Reset MySQL root password
Now when safe_mysqld running in one Terminal window, open up another Terminal window and execute this command
/usr/local/mysql/bin/mysql mysql
This opening up the MySQL console and opening the MySQL table so we can update MySQL root user. Write the reset query into the console as follows:
1. For MySQL 5.7+
As of MySQL 5.7, the password field has been renamed authentication_string
. When changing the password, use the following query to change the password.
mysql> UPDATE user SET authentication_string=PASSWORD("NEWPASSWORD") WHERE User='root';mysql> FLUSH PRIVILEGES;mysql> quit
Change out NEWPASSWORD with whatever password you want. Should be all set!
2. For MySQL 5.6 and below:
mysql> UPDATE user SET password=PASSWORD("NEWPASSWORD") WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> quit
Change out NEWPASSWORD with whatever password you want. Should be all set!
Step 4: Restart MySQL service: Once you’ve done that just exit the console “exit;” close the safe_mysqld execution and restart your MySQL server. Typically this can be done from ‘System Preferences
‘ > MySQL
> ‘Start MySQL Server
‘