Reset MySQL root / user password from command line
« on: September 13, 2008, 09:51:19 AM »
How to reset MySQL root / user password from MySQL command line:

There are several ways to reset MySQL root / user password. Below is the one of the simple way to reset it:

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) For example, if you want to change the password for root user:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

Note: MySQL stores the username and password in mysql database. Hence, we have use mysql database in step 2.