# **ALTER USER**

## **Grammar Description**

Modify the properties and password of the database user.

:::{note}
1. 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.
2. 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**

```sql
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**

```text
-- 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)
```

<!--select admin_1, mr.role_name from mo_catalog.mo_role mr, mo_catalog.mo_user mu, mo_catalog.mo_user_grant mur
where mr.role_id =mur.role_id and mu.user_id = mur.user_id
order by mu.user_id asc, mr.role_id ;-->
