ALTER ACCOUNT
Description
Modify account information.
Note
- The cluster administrator (i.e., the root user) can modify the password of the account it creates.
- Accounts themselves can modify their own passwords.
- Only the cluster administrator (i.e., the root user) can perform SUSPEND and RECOVER (OPEN) account operations.
Syntax
1. > ALTER ACCOUNT [IF EXISTS]
2. account auth_option [COMMENT 'comment_string']
4. auth_option: {
5. ADMIN_NAME [=] 'admin_name'
6. IDENTIFIED BY 'auth_string'
7. }
9. status_option: {
10. OPEN
11. | SUSPEND
12. }
Explanations
auth_option
Modifies the default account name and authorization mode of the account, auth_string specifies the password explicitly.
status_option
Set the state of the account. They are stored as VARCHAR in the mo_account table under the system database mo_catalog.
- SUSPEND: Suspend the account’s service; that is, the account can no longer access MatrixOne after the suspension; users who are accessing the account can continue to access, and after closing the session, they will no longer be able to access MatrixOne.
- OPEN: Resume a suspended account, after which the account will usually access MatrixOne.
comment
Account notes are stored as VARCHAR in the table mo_account in the system database mo_catalog.
COMMENT can be arbitrary quoted text, and the new COMMENT replaces any existing user comments. As follows:
1. mysql> desc mo_catalog.mo_account;
2. +----------------+--------------+------+------+---------+-------+---------+
3. | Field | Type | Null | Key | Default | Extra | Comment |
4. +----------------+--------------+------+------+---------+-------+---------+
5. | account_id | INT | YES | | NULL | | |
6. | account_name | VARCHAR(300) | YES | | NULL | | |
7. | status | VARCHAR(300) | YES | | NULL | | |
8. | created_time | TIMESTAMP | YES | | NULL | | |
9. | comments | VARCHAR(256) | YES | | NULL | | |
10. | suspended_time | TIMESTAMP | YES | | null | | |
11. +----------------+--------------+------+------+---------+-------+---------+
12. 6 rows in set (0.06 sec)
Examples
- Example 1: Modify the information on the account
1. -- Create a account named "root1" with password "111"
2. mysql> create account acc1 admin_name "root1" identified by "111";
3. Query OK, 0 rows affected (0.42 sec)
4. -- Change the initial password "111" to "Abcd_1234@1234"
5. mysql> alter account acc1 admin_name "root1" identified by "Abcd_1234@1234";
6. Query OK, 0 rows affected (0.01 sec)
7. -- Modify the comment for account "root1"
8. mysql> alter account acc1 comment "new account";
9. Query OK, 0 rows affected (0.02 sec)
10. -- Check to verify that the "new account" comment has been added to the account "root1"
11. mysql> show accounts;
12. +--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+
13. | account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |
14. +--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+
15. | acc1 | root1 | 2023-02-15 06:26:51 | open | NULL | 5 | 34 | 787 | 0.036 | new account |
16. | sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |
17. +--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+
18. 3 rows in set (0.19 sec)
- Example 2: Modify the status of the account
1. -- Create a account named "root1" with password "111"
2. mysql> create account accx admin_name "root1" identified by "111";
3. Query OK, 0 rows affected (0.27 sec)
4. -- Modify the account status to "suspend", that is, suspend user access to MatrixOne.
5. mysql> alter account accx suspend;
6. Query OK, 0 rows affected (0.01 sec)
7. -- Check if the modification status is successful.
8. mysql> show accounts;
9. +--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+
10. | account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |
11. +--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+
12. | accx | root1 | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 | 5 | 34 | 787 | 0.036 | new accout |
13. | sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |
14. +--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+
15. 2 rows in set (0.15 sec)
