How to recover the MySQL root password?

Well, this happens from time to time and is actually easy to fix, so here you are:

/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables & mysql -u root
you should now be in the MySQL shell as user root, now we just set a new password for the user root:

update mysql.user set password=PASSWORD("PASSWORD") where user='root'; quit

should be back to the command line, lets restart MySQL:
/etc/init.d/mysql restart


Well, that´s it :)

You cannot comment on this entry