Regardless of how you found your way to this post, your end goal must be to set or reset the root user password for your MySQL installation on Mac OS. This is another post I’m adding mostly for my own reference but if it can help someone else as a result that’s awesome.
First you’ll need to stop the MySQL service, this will vary based on your installation. In my case, I used MAMP so I can simply launch MAMP and then stop the service from there.
Next you’ll need to open up Terminal, you can find this under Applications -> Utilities or you can use spotlight by pressing Command + Space and searching for Terminal.
[simterm]
sudo mysqld_safe –skip-grant-tables;
[/simterm]
Now we need to launch another terminal window.
Connect to MySQL server from the newly launched terminal window.
[simterm]
mysql -u root
[/simterm]
Next we can set the root password. The procedures for MySQL older than MySQL 5.7 are slightly different then those of more modern versions.
For MySQL older than MySQL 5.7:
[simterm]
UPDATE mysql.user SET Password=PASSWORD(‘your-password’) WHERE User=’root’;
[/simterm]
For MySQL 5.7+:
[simterm]
USE mysql;
UPDATE mysql.user SET authentication_string=PASSWORD(“your-password”) WHERE User=’root’;
[/simterm]
Flush Privileges and then disconnect from MySQL
[simterm]
FLUSH PRIVILEGES;
\q
[/simterm]
Stop the mysqld_safe daemon and start the normal MySQL service back up. You should now be able to log in with your new password.
Questions? Comment below and I’ll try to help out if I can.
0 Comments for “Setting the MySQL Root User Password on Mac OS Server”