Purpose
This statement is used to modify the password of the current login user or another user in OceanBase Database.
Syntax
SET PASSWORD [FOR user] = password_option [RETAIN CURRENT PASSWORD]
password_option: {
PASSWORD('authstring')
|'hashstring'
}
Note
The optional RETAIN CURRENT PASSWORD clause is used to retain the old password while setting a new one. This clause is supported starting from V4.6.1 for dual-password scenarios.
Parameters
Parameter |
Description |
|---|---|
| FOR user | If the FOR user clause is not specified, it indicates that the password of the current user will be modified. Any successfully logged-in user can modify the password of the current user. If the FOR user clause is specified, it indicates that the password of the specified user will be modified. You must have the CREATE USER privilege in the MySQL database to modify the password of the specified user. |
| password_option | The password option. You can use PASSWORD('authstring') to specify a plaintext password, which will be automatically encoded by the system. Alternatively, you can directly use 'hashstring' to specify an encrypted hash string. |
| RETAIN CURRENT PASSWORD | Optional. Write this option after = on the right side of password_option. When this option is used, the old password remains valid together with the new password set this time, enabling dual-password authentication. |
Examples
Modify the password of the current user.
obclient> SET PASSWORD = PASSWORD('**1***');Modify the password of the
sqluser01user.obclient> SET PASSWORD FOR sqluser01 = PASSWORD('**2***');Change the password of the
sqluser01user while retaining the old password (dual-password).obclient> SET PASSWORD FOR sqluser01 = PASSWORD('**2***') RETAIN CURRENT PASSWORD;
