How to Recover a Lost MySQL Password

If you are using MySQL on Debian / Ubuntu Linux then use following command:

sudo /etc/init.d/mysql stop

sudo /usr/bin/mysqld_safe --skip-grant-tables &

mysql -u root mysql

UPDATE user SET password=PASSWORD('your_password') WHERE user = 'root';

FLUSH PRIVILEGES;

quit;

sudo pkill mysql_safe (or kill -9 pid)

sudo /etc/init.d/mysql restart

Cheers,