content_image/856059.jpg
The REPLACE ’ current_auth_string ’  clause performs password verification and is available as of MySQL 8.0.13. If given: 

• REPLACE  specifies the account current password to be replaced, as a cleartext (unencrypted) string. 

•The clause must be given if password changes for the account are required to specify the current password, as verification that the user attempting to make the change actually knows the current password. 

•The clause is optional if password changes for the account may but need not specify the current password. 

•The statement fails if the clause is given but does not match the current password, even if the clause is optional. 

• REPLACE  can be specified only when changing the account password for the current user. 

For more information about password verification by specifying the current password, see Section 6.2.15, “Password Management” . 

The RETAIN CURRENT PASSWORD  clause implements dual-password capability and is available as of MySQL 8.0.14. If given: 

• RETAIN CURRENT PASSWORD  retains an account current password as its secondary password, replacing any existing secondary password. The new password becomes the primary password, but clients can use the account to connect to the server using either the primary or secondary password. (Exception: If the new password specified by the SET PASSWORD  statement is empty, the secondary password becomes empty as well, even if RETAIN CURRENT PASSWORD  is given.) 

•If you specify RETAIN CURRENT PASSWORD  for an account that has an empty primary password, the statement fails. 

•If an account has a secondary password and you change its primary password without specifying RETAIN CURRENT PASSWORD , the secondary password remains unchanged. 

For more information about use of dual passwords, see Section 6.2.15, “Password Management” . 

SET PASSWORD  permits these auth_option  syntaxes: 

• = ’ auth_string ’ 

Assigns the account the given literal password. 

• TO RANDOM 

Assigns the account a password randomly generated by MySQL. The statement also returns the cleartext password in a result set to make it available to the user or application executing the statement. 

For details about the result set and characteristics of randomly generated passwords, see Random Password Generation. 

Random password generation is available as of MySQL 8.0.18. 

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

## Important 

Under some circumstances, SET PASSWORD  may be recorded in server logs or on the client side in a history file such as ~/.mysql_history , which means that 

