How to Update or Change Password for a Single User in MySQL and Reload Privileges

By Angsuman Chakraborty, Gaea News Network
Saturday, January 17, 2009

MySQL stores usernames and passwords in the user table inside the MySQL database. You can directly update a password using the following method to update or change passwords:

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

$ mysql -u root -p

2) Use the mysql database (type commands at the mysql> prompt):

mysql> use mysql;

3) Change password for a user:

mysql> update user set password=PASSWORD("newpass") where User='YOUR-USER-NAME';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

[P.S. - This works with PHP or Perl Scripting]

Discussion
March 13, 2010: 6:48 pm

Be carefull with the query:

update user set password=PASSWORD(”newpass”) where User=’YOUR-USER-NAME’;

If you have different passwords per host (for instance localhost vs %), this will update the password for both hosts.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :