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
#/etc/init.d/mysqld stop
- Then i run this service without password
#mysqld_safe --skip-grant-tables
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 output mysql>
- 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;
mysql> quit - Last step is stop mysql service
#/etc/init.d/mysqld stop
- Finish, and start mysqld and test new password
#/etc/init.d/mysqld start #mysql -u root -p
About this post
Posted: 2011-04-02
By: FortyPoundHead
Viewed: 898 times
Categories
Tip
Software Hack/Tweak
Tutorials
Attachments
Loading Comments ...
Comments
No comments have been added for this post.
Sorry. Comments are frozen for this article. If you have a question or comment that relates to this article, please post it in the appropriate forum.