Setting and changing passwords
To change the password of a user or to set a password for a user that doesn't have one, we can use the GRANT
statement, but that implies that we are adding permissions to a user. To change or set a password without changing any permissions; it's much easier to use the SET PASSWORD
statement. It has the following pattern:
SET PASSWORD FOR <user> = PASSWORD('<password>');
The following is an example of this:
SET PASSWORD FOR 'henry'@'%' = PASSWORD('niftypassword');
Note
Complete documentation of the
SET PASSWORD
statement is available at the following location: