Creates a database account for a PolarDB cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No CreateAccount

The operation that you want to perform. Set the value to CreateAccount.

DBClusterId String Yes pc-**************

The ID of the PolarDB cluster.

AccountName String Yes testacc

The name of the account. The name must meet the following requirements:

  • The name must start with a lowercase letter and end with a digit or a letter.
  • The name can contain lowercase letters, digits, and underscores (_).
  • The name must be 2 to 16 characters in length.
  • The name cannot be root, admin, or another account name that is reserved by the system.
AccountPassword String Yes Test1111

The password of the account. The password must meet the following requirements:

  • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
  • The password must be 8 to 32 characters in length.
  • Special characters include !@ # $ % ^ & * ( ) _ + - =
AccountType String No Normal

The type of the account. Valid values:

  • Normal: standard account
  • Super: privileged account
Note
  • If you leave this parameter empty, the default value Super is used.
  • If the database engine of the PolarDB cluster is PolarDB O Edition or the ApsaraDB PolarDB PostgreSQL-compatible edition, you can create multiple privileged accounts for the cluster. A privileged account is granted more permissions than a standard account. For more information about how to create a database account, see Create a database account.
  • If the database engine of the PolarDB cluster is the ApsaraDB PolarDB MySQL-compatible edition, only one privileged account can be created for the cluster. A privileged account is granted more permissions than a standard account. For more information about how to create a database account, see Create a database account.
AccountDescription String No testdes

The description of the account. The description must meet the following requirements:

  • It cannot start with http:// or https://.
  • It must be 2 to 256 characters in length.
DBName String No testdb

The name of the database that can be accessed by the account. To enter multiple database names, separate the names with commas (,).

Note Only standard accounts of clusters that run the engine of the ApsaraDB PolarDB MySQL-compatible edition support this parameter.
AccountPrivilege String No ReadWrite

The permissions of the account. Valid values:

  • ReadWrite: The account has the read and write permissions on the database.
  • ReadOnly: The account has the read-only permissions on the database.
  • DMLOnly: The account has the permissions only to execute DML statements on the database.
  • DDLOnly: The account has the permissions only to execute DDL statements on the database.
  • ReadIndex: The account has the read and index permissions on the database.
Note
  • If you leave this parameter empty, the default value ReadWrite is used.
  • If multiple database names are specified by the DBName parameter, you must grant corresponding permissions on the databases. Separate multiple permissions with commas (,). For example, if you want to grant the account the read and write permissions on DB1 and the read-only permissions on DB2, set DBName to DB1,DB2, and set AccountPrivilege to ReadWrite,ReadOnly.
  • Only standard accounts of clusters that run the engine the ApsaraDB PolarDB MySQL-compatible edition support this parameter.
ClientToken String No 6000170000591aed949d0f54a343f1a4233c1e7d1c5c******

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. The token is case-sensitive.

Response parameters

Parameter Type Example Description
RequestId String CED079B7-A408-41A1-BFF1-EC608E******

The ID of the request.

Examples

Sample requests

http(s)://polardb.aliyuncs.com/?Action=CreateAccount
&AccountName=testacc
&AccountPassword=Test1111
&DBClusterId=pc-**************
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateAccountResponse>
<RequestId>CED079B7-A408-41A1-BFF1-EC608E******</RequestId>
</CreateAccountResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "CED079B7-A408-41A1-BFF1-EC608E******"
}

Error codes

For a list of error codes, visit the API Error Center.