Purpose
You can use this statement to perform the following operations:
Change the password of an OceanBase Database user.
Lock or unlock a user. A locked user cannot log in to OceanBase Database.
Note
To execute this statement to perform an operation other than changing the password of the current user, you must have the
CREATE USERprivilege.Set the default roles activated for a user upon login.
Required privileges
To execute the ALTER USER statement, you must have the CREATE USER privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL mode.
Syntax
Change the password of a user.
ALTER USER 'user_name' IDENTIFIED BY 'password';Lock a user.
ALTER USER 'user_name' [ACCOUNT LOCK | ACCOUNT UNLOCK];Set the default roles activated for a user upon login.
ALTER USER user_name DEFAULT ROLE {NONE | ALL | role_name [, role_name ...]};
Parameters
| Parameter | Description |
|---|---|
| user_name | The username. |
| password | The new password. |
| ACCOUNT LOCK | Specifies to lock the user. |
| ACCOUNT UNLOCK | Specifies to unlock the user. |
| NONE | Specifies to deactivate all roles granted to the user. |
| ALL | Specifies to activate all roles granted to the user. |
| role_name | The name of the role to be activated. Separate multiple roles with commas (,). |
Examples
Change the password of the
sqluser01user to******.obclient> ALTER USER 'sqluser01' IDENTIFIED BY '******';Lock the
obsqluser01user.obclient> ALTER USER 'obsqluser01' ACCOUNT LOCK;Unlock the
obsqluser01user.obclient> ALTER USER 'obsqluser01' ACCOUNT UNLOCK;Specify to activate the
role001androle002roles granted to theuser001user by default when the user logs in.ALTER USER user001 DEFAULT ROLE role001, role002;