Change User Password

To change a user password, you need to UPDATE the user table in the mysql database and SET the new Password using the PASSWORD() function, using WHERE User = ‘user_name’ to select the desired user.

 

Logon as root run this command:

mysql> UPDATE mysql.user SET Password = PASSWORD(‘secret’) WHERE User = ‘root’;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0

 

 

Then run FLUSH PRIVILEGES, to tell MySQL to re-read those tables so that it will update the passwords in memory and allow the new passwords to be used:

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Leave a Reply