Recover a MySQL root password

Posted by Unknown on 08:56 with No comments

Recover a MySQL root password

Stop the MySQL server process
root@ub# /etc/init.d/mysql stop 

Start again with no grant tables
root@ub# mysqld_safe --skip-grant-tables &

Login to MySQL as root.
root@ub# mysql -u root
mysql> use mysql;

Set new password
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;

Exit MySQL and restart MySQL server
mysql> quit
root@ub# /etc/init.d/mysql stop
root@ub# /etc/init.d/mysql start
Categories: