Monday, August 10, 2009

how to recover mysql server root password?

If you have lost your mysql password for some "ding dong" reason, :P

here is how to recover them:
1. stop the mysqld service by: sudo /etc/init.d/mysqld stop
2. start: mysqld_safe --skip-grant-tables &
3. login without pwd: mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
4. stop mysql: sudo /etc/init.d/mysqld stop
5. start mysqld: sudo /etc/init.d/mysqld start
6. try login via: mysql -u root -p (with yournew pwd)

No comments: