What is my MySQL root password?

Where or how do I check MySQL root password? I don't have a .my.cnf file, I can't login to SQL console (it requires a password), I can't do anything.


Solution 1:

There is no way to lookup the password. It is encrypted. On many systems the root password is blank by default. On other systems you would have been asked to set the root password when you installed mysql. The password reset procedure is described here (http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html).

Solution 2:

If you manage to get a shell you can set it this way:

Start mysql with:

mysqld_safe --skip-grant-tables

Log in mysql

mysql --user=root mysql

Update the root password:

UPDATE user SET Password=PASSWORD('newpwd') WHERE User='root';
flush privileges;
exit;