SET PASSWORD [FOR user] = 'auth_string'
SET PASSWORD statement
assigns a password to a MySQL user account.
represents a cleartext (unencrypted) password.
ALTER USER user IDENTIFIED BY 'auth_string';
Under some circumstances,
PASSWORD may be recorded in server logs or on the
client side in a history file such as
~/.mysql_history, which means that
cleartext passwords may be read by anyone having read access
to that information. For information about the conditions
under which this occurs for the server logs and how to control
it, see Section 184.108.40.206, “Passwords and Logging”. For similar
information about client-side logging, see
Section 220.127.116.11, “mysql Logging”.
SET PASSWORD can be used with or
FOR clause that explicitly names a
FORclause, the statement sets the password for the named account, which must exist:
SET PASSWORD FOR 'jeffrey'@'localhost' = 'auth_string';
FORclause, the statement sets the password for the current user:
SET PASSWORD = 'auth_string';
Any client who connects to the server using a nonanonymous account can change the password for that account. To see which account the server authenticated you as, invoke the
Setting the password for a named account (with a
FOR clause) requires the
UPDATE privilege for the
mysql database. Setting the password for
yourself (for a nonanonymous account with no
FOR clause) requires no special privileges.
variable is enabled,
SUPER privilege in addition to
any other required privileges.
clause is given, the account name uses the format described in
Section 6.2.4, “Specifying Account Names”. For example:
SET PASSWORD FOR 'bob'@'%.example.org' = 'auth_string';
The host name part of the account name, if omitted, defaults to
SET PASSWORD interprets the
string as a cleartext string, passes it to the authentication
plugin associated with the account, and stores the result
returned by the plugin in the
account row. (The plugin is given the opportunity to hash the
value into the encryption format it expects. The plugin may use
the value as specified, in which case no hashing occurs.)