ALTER USER¶
Grammar Description¶
Modify the properties and password of the database user.
Note
The tenant can modify the password of the user it creates, and only modify the password of 1 user at a time. The modified password will take effect next time, and the current session will not be interrupted.
Users can modify their password. The modified password will take effect next time you log in and the current session will not be interrupted.
Grammar Structure¶
ALTER USER [IF EXISTS]
user auth_option
auth_option: {
IDENTIFIED BY 'auth_string'}
Parameter definition¶
auth_option¶
Modify the user’s account name and authorization method. auth_string means explicitly return the specified password.
Example¶
-- Create a user with a password named "admin_1" with "123456"
mysql> create user admin_1 identified by '123456';
Query OK, 0 rows affected (0.02 sec)
-- Change the user's initial password "123456" to "111111"
mysql> alter user 'admin_1' identified by '11111';
Query OK, 0 rows affected (0.02 sec)
-- Check whether the password is modified successfully
mysql> select * from mo_catalog.mo_user;
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 0 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |
| 1 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |
| 2 | localhost | admin_1 | 11111 | unlock | 2023-04-21 06:21:31 | NULL | PASSWORD | 1 | 0 | 1 |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 rows in set (0.01 sec)