Skip to main content
Create and manage users using the native authentication within the database through SQL commands. The database native authentication is a password-based authentication method. In addition to that, the database also supports integrating with external authentication systems such as LDAP. For more instructions, see Authenticate with Security Integration. Note Users with the system-defined role user_admin can create users, alter users, and drop users in the database. After a cluster is created, the system automatically generates a root user with root privileges. Because the root user and role have all privileges of the system, we recommend that you create new users and roles for subsequent operations to prevent any risky operations. Keep the password of the root user properly.

Create user

You can create a user by specifying the user identity, the authentication method, and optionally the default role. To enable the native authentication for the user, you need to explicitly specify the password in plaintext or ciphertext. The following example creates the user jack, allows it to connect only from the IP address 172.10.1.10, enables the native authentication, sets the password to 12345 in plaintext, and assigns the role example_role to it as its default role:
Note
  • The database encrypts users’ passwords before storing them. You can get the encrypted password using the password() function.
  • A system-defined default role PUBLIC is assigned to a user if no default role is specified during user creation.
The default role of a user is automatically activated when the user connects to the database. For instructions on how to enable all (default and granted) roles for a user after connection, see Enable all roles. For more information and advanced instructions on creating a user, see CREATE USER.

Alter user

You can alter the password, default role, or property for a user. For instructions on how to alter the default role for a user, see Alter default role.

Alter the property of a user

You can set the property of a user using ALTER USER. The following example sets the maximum number of connections for user jack to 1000. User identities that have the same user name share the same property. Therefore, you only need to set the property for jack and this setting takes effect for all the user identities with the user name jack.

Reset password for a user

You can reset the password for a user using SET PASSWORD or ALTER USER.
NOTE
  • Any user can reset their own passwords without needing any privileges.
Both the following examples reset the password of jack to 54321:
  • Reset the password using SET PASSWORD:
  • Reset the password using ALTER USER:

Reset lost root password

Only the root user itself can set its password. If you have lost the password of the root user and cannot connect to the database, you can reset it by following these procedures:
  1. Add the following configuration item to the configuration files fe/conf/fe.conf of all FE nodes to disable user authentication:
  2. Restart all FE nodes to allow the configuration to take effect.
  3. Connect from a MySQL client to the database via the root user. You do not need to specify the password when user authentication is disabled.
  4. Reset the password for the root user.
  5. Re-enable user authentication by setting the configuration item enable_auth_check to true in the configuration files fe/conf/fe.conf of all FE nodes.
  6. Restart all FE nodes to allow the configuration to take effect.
  7. Connect from a MySQL client to the database using the root user and the new password to verify whether the password is reset successfully.

Drop a user

You can drop a user using DROP USER. The following example drops the user jack:

View users

You can view all the users within the cluster using SHOW USERS.

View user property

You can view the property of a user using SHOW PROPERTY. The following example shows the property of the user jack:
Or to view a specific property: