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 password, applicable for dual-password scenarios. This feature is available from V4.4.2 BP1 onwards.
Parameters
Parameter |
Description |
|---|---|
| FOR user | If the FOR user clause is not specified, the password of the current user is modified. Any successfully logged-in user can modify the password of the current user. If the FOR user clause is specified, the password of the specified user is modified. To modify the password of the specified user, you must have the CREATE USER privilege in the MySQL database. |
| password | By default, the password is transmitted in plaintext and will be encoded in the kernel. |
| RETAIN CURRENT PASSWORD | Optional. Specify this option after the password_option on the right side of the = sign. This option takes effect along with the new password set in this operation. It retains the old password before the password change and enables dual passwords. |
Examples
Modify the password of the current user.
obclient> SET PASSWORD = PASSWORD('**1***'); Query OK, 0 rows affectedModify the password of the
sqluser01user.obclient> SET PASSWORD FOR sqluser01 = PASSWORD('**2***'); Query OK, 0 rows affectedModify the password of the
sqluser01user and retain the old password (double password).obclient> SET PASSWORD FOR sqluser01 = PASSWORD('**2***') RETAIN CURRENT PASSWORD; Query OK, 0 rows affected
