This topic describes how to create a database account for an AnalyticDB for PostgreSQL instance.

Background information

AnalyticDB for PostgreSQL provides the following types of database accounts:

  • Privileged account: an account that has all permissions on all databases. The first account created for an instance in the console is a privileged instance.
  • Standard accounts: accounts that have all permissions only on their authorized databases.
    Note Permissions include SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, and TRIGGER. For information about how to configure permissions, see Manage users and permissions.

Precautions

  • Before you use databases in an AnalyticDB for PostgreSQL instance , you must create a privileged account.
  • Standard accounts cannot be created by using the console. For information about how to create standard accounts, see Execute SQL statements to create accounts.
  • After you create a privileged account for an instance, you cannot delete the privileged account.

Create a privileged account

  1. Log on to the AnalyticDB for PostgreSQL console.
  2. In the upper-left corner of the console, select the region where the instance resides.
  3. Find the instance that you want to manage and click its ID.
  4. In the left-side navigation pane, click Account Management.
  5. Click Create Account.
  6. In the Create Account panel, specify the following parameters.
    Parameter Description
    Account The name of the privileged account.
    • The name can contain lowercase letters, digits, and underscores (_).
    • The name must start with a lowercase letter and end with a lowercase letter or a digit.
    • The name cannot start with gp.
    • The name must be 2 to 16 characters in length.
    New Password The password of the privileged account.
    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
    • The following special characters are supported:

      ! @ # $ % ^ & * ( ) _ + - =

    • The password must be 8 to 32 characters in length.
    Confirm Password Enter the password of the account again.
  7. Click OK.
Notice After the account is created, you can click Reset Password in the Actions column to modify the account password. To ensure data security, we recommend that you change your password on a regular basis and do not use passwords that you have used before.

Execute SQL statements to create accounts

  • Create a privileged account.
    CREATE ROLE <Account name> WITH LOGIN ENCRYPTED PASSWORD <Password> RDS_SUPERUSER;

    Example:

    CREATE role admin0  WITH LOGIN ENCRYPTED PASSWORD '111111' rds_superuser;
  • Create a standard account.
    CREATE ROLE <Account name> WITH LOGIN ENCRYPTED PASSWORD <'Password'>;

    Example:

    CREATE role test1 WITH LOGIN ENCRYPTED PASSWORD '111111';

Related operations

Operation Description
CreateAccount Creates a privileged account.
DescribeAccounts Queries the accounts created on an AnalyticDB for PostgreSQL instance.
ModifyAccountDescription Modifies the name of an account for an instance.
ResetAccountPassword Resets the password of an account for an instance.