Use this MySQL statement to change the password for a user account.


Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

SET PASSWORD [FOR 'user'@'host'] = PASSWORD('password')


Use this MySQL statement to change the password for a user account. The user name and host must be given. The change of password will apply only to the combination given of user name and host. It won't apply to other hosts for the same user in the grant tables.


To get a list of user accounts on a MySQL server, enter the following MySQL statement:

SELECT User, Host FROM mysql.user;

If the FOR clause is not given with the SET PASSWORD statement, the current user account is assumed. The PASSWORD( ) function will encrypt the password given.

This MySQL statement does not need to be followed by a FLUSH PRIVILEGES statement. It will update automatically the privileges cache for the new password. If you updated your MySQL server from a version before 4.1 to a new version, you may have problems changing a user account's password and cause the user account's password to become invalid. You may need to run the mysql_fix_privilege_tables utility to change the Password column in the user table in the mysql database.

An example follows of changing a user account's password.

SET PASSWORD FOR 'kenneth'@'localhost' = PASSWORD('his_password');