Lock and unlock users
When a user no longer needs to access the database, the administrator can lock the user. Locked users cannot log in to seekdb. The administrator can also unlock a user to reactivate them.
Prerequisites
Locking and unlocking users is typically performed by administrators. If a regular user needs to perform these actions, they must have the global ALTER USER privilege. For information about how to check the privileges you currently have, see View user privileges. If you do not have the global ALTER USER privilege, contact your administrator to grant it. For information about how to directly grant privileges to a user, see Directly grant privileges.
Procedure
-
Log in to seekdb.
-
Execute the following statement to lock or unlock a user.
The statement is as follows:
ALTER USER user_name ACCOUNT LOCK | UNLOCK;Example:
-
Lock a user
ALTER USER demo ACCOUNT LOCK;mysql -h127.0.0.1 -uroot -P2881 -p******ERROR 3118 (HY000): User locked -
Unlock a user
ALTER USER demo ACCOUNT UNLOCK;Query OK, 0 rows affected (0.02 sec)mysql -h127.0.0.1 -uroot -P2881 -p******Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3221537922
Server version: 5.7.25 OceanBase 4.3.5.3 SeekDB (r1.0.0.0) (Built 100000262025111218-5343637512e28c346f938516af53b7879d4d5974 Nov 12 2025)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
-
-
After locking or unlocking a user, the administrator can check the
is_lockedfield in theDBA_OB_USERSview to confirm the user's status.Example:
SELECT user_name,is_locked FROM oceanbase.DBA_OB_USERS WHERE user_name='demo';+-----------+-----------+
| user_name | is_locked |
+-----------+-----------+
| demo | NO |
+-----------+-----------+
1 row in setIf the value of the
is_lockedfield isYES, the user is locked. If the value isNO, the user is unlocked.
References
For more information about the ALTER USER statement, see ALTER USER.