How To Reset MySQL Root Password

February 12th, 2010 by @HKw@! | Filed under centos, Linux, Open Source.

I setup MySQL Server on CentOS few month ago, but i forgot the root password for MySQL. How to reset the password?

You can recover MySQL database server password with following steps.

Step # 1: Stop the MySQL server process.

service mysqld stop

Step # 2: Start the MySQL (mysqld) in safe mode with the –skip-grant-tables option

mysqld_safe --skip-grant-tables -u root &

Step # 3: Connect to mysql server as the root user.

mysql -u root

Step # 4: Setup new mysql root account password.

UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';

Step # 5: Flush Privileges

FLUSH PRIVILEGES;

Step # 5: Quit MySQL command line

quit

Step # 6 Restart MySQL deamon

service mysqld restart

Step # 7 Log in as root to test the root password

mysql -u root -p
Share

Tags: , ,

Leave a Reply

BlogCatalog