Recover MySQL root password
It happens from time to time. For me, it happens after being on a long vacation. I forget my password, and the root password. Shame on me. Recovering is simpler than you think!
- Open console and stop mysql service
- Then i run this service without password
You can also run it as a background if you would not use another console (shell)
#mysqld_safe --skip-grant-tables &
- Then i open another console and connect to mysql
#mysql -u root
- Next, i setup new password for root user
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
- Last step is stop mysql service
- Finish, and start mysqld and test new password
#mysql -u root -p
About the Author
FortyPoundHead has posted a total of 1974 articles.
Comments On This Post
No comments on this post yet!
Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.
Or you can drop a note to the administrators if you're not sure where you should post.