content_image/832004.jpg
ALTER USER ’jeffrey’@’localhost’ ACCOUNT LOCK; ALTER USER ’jeffrey’@’localhost’ ACCOUNT UNLOCK; 

Example: Require an account to connect using SSL and establish a limit of 20 connections per hour: 

ALTER USER ’jeffrey’@’localhost’ REQUIRE SSL WITH MAX_CONNECTIONS_PER_HOUR 20; 

Example: Alter multiple accounts, specifying some per-account properties and some global properties: 

ALTER USER ’jeffrey’@’localhost’ IDENTIFIED BY ’ jeffrey_new_password ’, ’jeanne’@’localhost’, ’josh’@’localhost’ IDENTIFIED BY ’ josh_new_password ’ REPLACE ’ josh_current_password ’ RETAIN CURRENT PASSWORD REQUIRE SSL WITH MAX_USER_CONNECTIONS 2 PASSWORD HISTORY 5; 

The IDENTIFIED BY  value following jeffrey  applies only to its immediately preceding account, so it changes the password to ’ jeffrey_new_password ’  only for jeffrey . For jeanne , there is no per- account value (thus leaving the password unchanged). For josh , IDENTIFIED BY  establishes a new password ( ’ josh_new_password ’ ), REPLACE  is specified to verify that the user issuing the ALTER USER  statement knows the current password ( ’ josh_current_password ’ ), and that current password is also retained as the account secondary password. (As a result, josh  can connect with either the primary or secondary password.) 

The remaining properties apply globally to all accounts named in the statement, so for both accounts: 

•Connections are required to use SSL. 

•The account can be used for a maximum of two simultaneous connections. 

•Password changes cannot reuse any of the five most recent passwords. 

Example: Discard the secondary password for josh , leaving the account with only its primary password: 

ALTER USER ’josh’@’localhost’ DISCARD OLD PASSWORD; 

In the absence of a particular type of option, the account remains unchanged in that respect. For example, with no locking option, the locking state of the account is not changed. 

## ALTER USER Authentication Options 

An account name may be followed by an auth_option  authentication option that specifies the account authentication plugin, credentials, or both. It may also include a password-verification clause that specifies the account current password to be replaced, and clauses that manage whether an account has a secondary password. 

<img src='content_image/832004.jpg'>

## Note 

Clauses for random password generation, password verification, and secondary passwords apply only to accounts that use an authentication plugin that stores credentials internally to MySQL. For accounts that use a plugin that performs authentication against a credentials system that is external to MySQL, password management must be handled externally against that system as well. For more 

