How do I retrieve my MySQL username and password?

Marcel picture Marcel · Aug 7, 2008 · Viewed 594.8k times · Source

I lost my MySQL username and password. How do I retrieve it?

Answer

Xenph Yan picture Xenph Yan · Aug 7, 2008

Stop the MySQL process.

Start the MySQL process with the --skip-grant-tables option.

Start the MySQL console client with the -u root option.

List all the users;

SELECT * FROM mysql.user;

Reset password;

UPDATE mysql.user SET Password=PASSWORD('[password]') WHERE User='[username]';

But DO NOT FORGET to

Stop the MySQL process

Start the MySQL Process normally (i.e. without the --skip-grant-tables option)

when you are finished. Otherwise, your database's security could be compromised.