Wednesday, October 26, 2011

How to reset MySQL root password


1. edit /etc/mysql/my.cnf
add "skip-grant-tables" in mysqld settings section

2. restart mysqld
/etc/init.d/mysql restart

3. connect mysql database
mysql -u root -p mysql

4. update root password
>update user set password=PASSWORD("12345") where user='root';
quit

5. delete the configuration added in step 1

6. restart mysqld again
/etc/init.d/mysql restart

DONE!

2 comments:

Unknown said...

Great post.

One correct though, the update statement should specify mysql.user as the table name:

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

Alex jon said...

I don’t suppose many of websites give this kind of information. password vault