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.
sudo mysqld_safe –skip-grant-tables;
Now we need to launch another terminal window.
Connect to MySQL server from the newly launched terminal window.
mysql -u root
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:
UPDATE mysql.user SET Password=PASSWORD(‘your-password’) WHERE User=’root’;
For MySQL 5.7+:
UPDATE mysql.user SET authentication_string=PASSWORD(“your-password”) WHERE User=’root’;
Flush Privileges and then disconnect from MySQL
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.