user_admin role can modify information for other users.
Syntax
Parameters
-
user_identityconsists of two parts, “user_name” and “host”, in the format ofusername@'userhost'. For the “host” part, you can use%for fuzzy match. If “host” is not specified, ”%” is used by default, meaning that the user can connect to the database from any host. However, when you use this statement withSET PROPERTIESto modify the user properties, you must specify theusernameinstead ofuser_identity. -
auth_optionspecifies the authentication method. Currently, three authentication methods are supported: the database native password, mysql_native_password, and “authentication_ldap_simple”. The database native password is the same as mysql_native_password in logic but slightly differs in syntax. One user identity can use only one authentication method. You can use ALTER USER to modify users’ passwords and authentication methods.
Note: the database encrypts users’ passwords before storing them.
-
DEFAULT ROLEsets the default role for the user.Before you run ALTER USER to set default roles, make sure that all the roles have been assigned to users. The roles are automatically activated after the user logs in again. -
SET PROPERTIESsets user properties, including the maximum user connection number (max_user_connections), password policy, catalog, database, or session variables on the user level. User-level session variables take effect as the user logs in. This feature is supported from v3.3.3.TipSET PROPERTIESworks on user instead of user identity. Therefore, when modifying the user properties, you must specify theusernameinstead ofuser_identityin theALTER USERstatement.- Global variables and read-only variables cannot be set for a specific user.
- Variables take effect in the following order: SET_VAR > Session > User property > Global.
PASSWORD_POLICYcan be set only byALTER USER ... SET PROPERTIES. It is not supported inCREATE USER.- If a user does not have
PASSWORD_POLICYconfigured, the system-level password policy is used. IfPASSWORD_POLICYis configured for the user, it overrides the system-level password policy for password validation, password expiration, and password retry lockout. - A password policy that is still bound to users cannot be dropped.
- You can use SHOW PROPERTY to view the properties of a specific user.
Examples
Example 1: Change user’s password to a plaintext password.You can get the encrypted password using the password() function.Example 3: Change the authentication method to LDAP.
db_admin and user_admin. Note that the user must have been assigned these two roles.
Note: By default, the public role is still activated for the user.
Example 8: Set the maximum user connection number to 600.
hive_catalog.
test_db in the default catalog.
query_timeout to 600 for the user.
pwd_policy_1 to the user.