PolarDB-X supports two types of database accounts: privileged accounts and standard accounts. A newly created instance has no accounts by default. This topic describes how to create accounts and perform common account management tasks in the PolarDB-X console.
Account types
| Account type | Description |
|---|---|
| Privileged account | One privileged account is allowed per instance. It has full permissions on all databases in the instance and can close connections established by standard accounts. Create and manage it through the console or API operations. You cannot delete a privileged account after it is created. |
| Standard account | Multiple standard accounts are allowed per instance (the maximum is determined by the kernel engine). Each standard account must be granted permissions on specific databases. Manage standard accounts through the console, API operations, or SQL statements. Standard accounts cannot create or manage other accounts, or close connections established by other accounts. |
Account types cannot be changed after creation. To switch an account's type, delete it and create a new account with the same username.
Access restrictions
The host value of accounts created in the console is
%, which allows connections from any IP address in the whitelists. To restrict access to specific hosts, use the privileged account to log in and run theCREATE USERstatement:-- Replace <username>, <host>, and <password> with actual values CREATE USER <username>@<host> IDENTIFIED BY '<password>';To grant instance-level access to RAM users, see Create a RAM user.
Prerequisites
Before you begin, ensure that you have:
A PolarDB-X instance
Access to the PolarDB-X console
Create an account
Log on to the PolarDB-X console.
In the top navigation bar, select the region where the instance is deployed.
On the Instances page, click the PolarDB-X 2.0 tab.
Find the instance and click its ID.
In the left-side navigation pane, choose Configuration Management > Account Management.
Click Create an account and configure the following parameters.
Parameter Description Account name The username for the account. Requirements: up to 16 characters; lowercase letters, digits, and underscores ( _) only; must start with a lowercase letter and end with a lowercase letter or digit; must be unique.Account types Select privileged account or standard account. Authorization database The databases the account can access. This parameter applies to standard accounts only and is optional—you can grant database permissions after the account is created. To add databases: select one or more databases in the Unauthorized database section and click the
icon to move them to the Authorized database section. Then select the permissions to grant: Read and Write, Read Only, DML Only, or DDL Only. To apply the same permission to all selected databases at once, click the permission name (for example, All Read and Write) next to Authorized database.Password The account password. Requirements: 8–20 characters; must include at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ( @ # $ % ^ & + =).Confirm password Re-enter the password to confirm. Descr (Optional) A description to help identify the account. Maximum 256 characters. Click OK.
Reset the password of a database account
Log on to the PolarDB-X console.
In the top navigation bar, select the region where the instance is deployed.
On the Instances page, click the PolarDB-X 2.0 tab.
Find the instance and click its ID.
In the left-side navigation pane, choose Configuration Management > Account Management.
Find the account and click Change Password in the Actions column.
Enter and confirm the new password, then click OK.
The password must be 8–20 characters and include at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (
@ # $ % ^ & + =).
Modify permissions for a standard account
The privileged account has full permissions on all databases. Only standard account permissions can be modified.
Log on to the PolarDB-X console.
In the top navigation bar, select the region where the instance is deployed.
On the Instances page, click the PolarDB-X 2.0 tab.
Find the instance and click its ID.
In the left-side navigation pane, choose Configuration Management > Account Management.
Find the account and click Modify Permissions in the Actions column.
In the Unauthorized database section, select one or more databases and click the
icon to move them to the Authorized database section.In the Authorized database section, select the permissions to grant: Read and Write, Read Only, DML Only, or DDL Only. To apply the same permission to multiple databases at once, click the permission name (for example, All DDL Only) next to Authorized database.
Click OK.
Delete an account
If you delete an account, clients that use the account will fail to connect to the database. Proceed with caution.
Log on to the PolarDB-X console.
In the top navigation bar, select the region where the instance is deployed.
On the Instances page, click the PolarDB-X 2.0 tab.
Find the instance and click its ID.
In the left-side navigation pane, choose Configuration Management > Account Management.
Find the account and click Delete in the Actions column.
In the confirmation dialog, click OK.