Quickest way to reset mysql root password

Last updated on April 14, 2024 am

If you forgot root password for MySQL, this is the quickest way to reset it. You need to have root access to the box.

service mysql stop

wait until MySQL shuts down. Then run

mysqld_safe --skip-grant-tables &

then you will be able to login as root with no password.

mysql -u root

In MySQL command line prompt issue the following command:

mysql> use mysql;
mysql> UPDATE user SET password=PASSWORD('the_new_password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

At this time your root password is reset and MySQL will now know the privileges and you'll be able to login with your new password:

mysql -u root -p


Quickest way to reset mysql root password
https://mingster.com/2009/08/30/quickest-way-to-reset-mysql-root-password/
Author
mingster
Posted on
August 30, 2009
Licensed under