Here I want to describe tutorial which works on my Mac.

MySQL version: mysql  Ver 14.14 Distrib 5.7.20, for macos10.12 (x86_64) using  EditLine wrapper
Mac OS version: Sierra 10.12.6

Please take care about root access in production environment. I’m feel free to connect to my MySQL db using root because it is my development environment.

So, to change root password which you have forgot/loose you need run couple of commands and do couple of additional steps.

1. Stop your MySQL server using System Preferences. Just open System Preferences–>MySQL and click “Stop MySQL Server” like on screenshot below:

2. Open Terminal and run next command:

Command output should be the next:

Now MySQL launched in the save mode.

3. Open new (second) terminal window and run the next command in it. Before it be sure you have mysqld in the PATH.

Output should be next:

You enter in the MySQL console. Now we need change password in the settings mysql table.

4. Run next command in the MySQL console to change the root password

Before run the command you need replace YOUR_NEW_PASSWORD_SHOULD_BE_HERE with your new root password.

Output should be next:

If you will see Query OK, 1 row affected then all is ok and we can exit MySQL console. You can do it using next command:

Now you need restart MySQL using System Preferences. Just click on “Start MySQL Server”

If you can’t do it using System Preferences then you need do it using Activity Monitor tool. You need open “CPU” tab then find and stop mysqld process.

Process “Force quit”  button located in the top-left corner. Have a look screenshot.

Hope it help you.
Let me know if you know better approach.




Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.