How to Recover MySQL Root Password

Stop the MySQL server:

/etc/init.d/mysql stop

Start the MySQL server w/o password:

mysqld_safe --skip-grant-tables &

Connect to the MySQL server:

mysql -u root

Set a new MySQL root password:

use mysql;
update user set password=PASSWORD("NEW-PASSWORD") where User='root';
flush privileges;
quit

Stop the MySQL server:

/etc/init.d/mysql stop

Start the MySQL server:

/etc/init.d/mysql start

More Related Posts