Tip Only users with the
user_admin role has the privilege to perform this operation.
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. Theuser_namepart is matched literally:app_userdoes not matchapp-user. Wildcard matching applies only to thehostpart. Native-password usernames are case-sensitive; LDAP users follow theauthentication_ldap_case_insensitiveconfiguration. For the naming conventions of usernames, see System limits. -
auth_optionspecifies the authentication method. Currently, five authentication methods are supported: the database native password,mysql_native_password,authentication_ldap_simple, JSON Web Token (JWT) Authentication, and OAuth 2.0 Authentication. The database native password is the same asmysql_native_passwordin logic but slightly differs in syntax. One user identity can use only one authentication method.Note StarRocks encrypts users’ passwords before storing them. For details ofauth_propertiesfor JSON Web Token (JWT) Authentication and OAuth 2.0 Authentication, see the corresponding documents: -
DEFAULT ROLE <role_name>[, <role_name>, ...]: If this parameter is specified, the roles are automatically assigned to the user and activated by default when the user logs in. If not specified, this user does not have any privileges. Make sure that all the roles that are specified already exist. -
PROPERTIESsets user properties, including the maximum user connection number (max_user_connections), password policy (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.TipPROPERTIESworks on user instead of user identity.PASSWORD_POLICYmust reference an existing password policy. When set, it takes precedence over the system-level password policy for that user.- 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.
- You can use SHOW PROPERTY to view the properties of a specific user.
Examples
Example 1: Create a user using a plaintext password with no host specified, which is equivalent tojack@'%'.
'172.10.1.10'.
'172.10.1.10'.
Note: You can get the encrypted password using the password() function.Example 4: Create a user who is allowed to log in from a domain name ‘example_domain’.
db_admin and user_admin as the default roles for the user.
600.
hive_catalog.
test_db in the default catalog.
query_timeout to 600 for the user.