| title | Manage Database Users and Roles |
|---|---|
| summary | Learn how to manage database users and roles in the TiDB Cloud console. |
This document describes how to manage database users and roles using the SQL Users page in the TiDB Cloud console.
Note:
- The SQL Users page is in beta and is only available upon request. To request this feature, click ? in the lower-right corner of the TiDB Cloud console, and then click Support Tickets to go to the Help Center. Create a ticket, fill in "Apply for the SQL Users page" in the Description field, and then click Submit.
- Database users and roles are independent of organization and project users and roles. Database users are used to access databases in a TiDB cluster, while organization and project users are used to access organizations and projects in the TiDB Cloud console.
- In addition to the SQL Users page, you can also manage database users and roles by connecting to your cluster with a SQL client and writing SQL statements. For more information, see TiDB User Account Management.
In TiDB Cloud, you can grant both a built-in role and multiple custom roles (if available) to a SQL user for role-based access control.
-
Built-in roles
TiDB Cloud provides the following built-in roles to help you control the database access of SQL users. You can grant one of the built-in roles to a SQL user.
Database AdminDatabase Read-WriteDatabase Read-Only
-
Custom roles
In addition to a built-in role, if your cluster has custom roles that are created using the
CREATE ROLEstatement, you can also grant these custom roles to a SQL user when you create or edit SQL users in the TiDB Cloud console.
After a SQL user is granted both a built-in role and multiple custom roles, the user's permissions will be the union of all the permissions derived from these roles.
- To manage database users and roles using the SQL Users page, you must be in the
Organization Ownerrole of your organization or theProject Ownerrole of your project. - If you are in the
Project Data Access Read-WriteorProject Data Access Read-Onlyrole of a project, you can only view database users on the SQL Users page of that project.
To view SQL users of a cluster, take the following steps:
-
On the Clusters page of your project, click the name of your target cluster to go to its overview page.
Tip:
You can use the combo box in the upper-left corner to switch between organizations, projects, and clusters.
-
In the left navigation pane, click Settings > SQL Users.
To create a SQL user for a cluster, take the following steps:
-
Navigate to the SQL Users page of your cluster.
-
Click Create SQL User in the upper-right corner.
A dialog for the SQL user configuration is displayed.
-
In the dialog, provide the information of the SQL user as follows:
-
Enter the name of the SQL user.
-
Either create a password for the SQL user or let TiDB Cloud automatically generate a password for the user.
-
Grant roles to the SQL user.
-
Built-in Role: you need to select a built-in role for the SQL user in the Built-in Role drop-down list.
-
Custom Role: if your cluster has custom roles that are created using the
CREATE ROLEstatement, you can grant custom roles to the SQL user by selecting the roles from the Custom Role drop-down list. Otherwise, the Custom Roles drop-down list is invisible here.
-
For each SQL user, you can grant a built-in role and multiple custom roles (if any).
-
-
Click Create.
To edit the password or roles of a SQL user, take the following steps:
-
Navigate to the SQL Users page of your cluster.
-
In the row of the SQL user to be edited, click ... in the Action column, and then click Edit.
A dialog for the SQL user configuration is displayed.
-
In the dialog, you can edit the user password and roles as needed, and then click Update.
Note:
The roles of the default
<prefix>.rootuser do not support modification. You can only change the password.
To delete a SQL user, take the following steps:
-
Navigate to the SQL Users page of your cluster.
-
In the row of the SQL user to be deleted, click ... in the Action column, and then click Delete.
Note:
The default
<prefix>.rootuser does not support deletion. -
Confirm the deletion.