Changing a MySQL user's password

To set the password of an existing user, you use:

SET PASSWORD FOR 'user'@'host' = PASSWORD('newpass');

An equivalent command is:

UPDATE mysql.user SET Password=PASSWORD('newpass')
  WHERE User='user' AND Host='host';
FLUSH PRIVILEGES;

Things to note:
MySQL 4.1 and newer use a new password hashing algorithm (unless the old-passwords option is specified in my.cnf), and MySQL clients older than 4.1 won't be able to authenticate against the new password format. This is important to note when changing passwords on a server that has been upgraded from a pre-4.1 version of MySQL.

Submitted by jkelly on Sat, 2006-08-12 03:26. categories [ | ] login or register to post comments