Recover mysql root password

It happens quite often, that You need to do something on database, which was installed long long time ago. And nobody remembers the root password.

Kinda good practice is to save mysql password in root user directory with a “.” in front of it (hidden), for example .my.cnf
Nobody can read root users directory, except root, and anyway, root user can change mysql password at any time, so it’s not an security issue.
If all users are able to see root users directory, that is a problem :)

Easy steps how to recover mysql root password.

That’s it :)


If You need, below are the same steps in details:

“#” means root shell

1. Stopping mysql service

2. Starting mysql without permissions and passwords

3. Loging in to mysql as root user without password

5. Choosing database where all grants are

6. Changing root password

7. Apply changes

8. Quit mysql shell

9. Stop mysql service running without permissions

10. Start normal mysql process

11. Here You go, try Your new password :)

Leave a Reply