You can call this operation to grant access permissions on one or more databases in a specified ApsaraDB for PolarDB cluster to a standard database account.

If the specified account already has access permissions on the specified database, the operation directly returns a successful response.

Before you call this operation, ensure that the cluster is in the running state.

Note
  • Only PolarDB MySQL is supported.
  • By default, privileged accounts have all permissions on databases.

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
AccountName String Yes testacc_01

The name of the account.

AccountPrivilege String Yes ReadOnly

The permissions of the database account on the database. Valid values:

  • ReadWrite: read and write permissions.
  • ReadOnly: read-only permissions.
  • DMLOnly: executes only data manipulation language (DML) statements.
  • DDLOnly: executes only data definition language (DDL) statements.
Note The number of account permissions specified by the AccountPrivilege parameter must be the same as that of database names specified by the DBName parameter. Each account permission must correspond to a database name in sequence. For example, if you specify DBName to test1,test2 and AccountPrivilege to ReadWrite,ReadOnly, it indicates the read/write permissions on the test1 database and the read-only permissions on the test2 database are granted to the specified account.
DBClusterId String Yes pc-xxxxxxxxxxxxxxxx

The ID of the cluster.

DBName String Yes testdb_1

The name of the database whose access permissions are to be granted to the database account. You can grant access permissions on one or more databases to the database account. Separate multiple databases with commas (,).

AccessKeyId String No key-test

The AccessKey ID provided to you by Alibaba Cloud.

Action String No GrantAccountPrivilege

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

Response parameters

Parameter Type Example Description
RequestId String 2FED790E-FB61-4721-8C1C-07C627FA5A19

The ID of the request.

Examples

Sample requests


http(s)://[Endpoint]/? Action=GrantAccountPrivilege
&AccountName=testacc_01
&AccountPrivilege=ReadOnly
&DBClusterId=pc-xxxxxxxxxxxxxxxx
&DBName=testdb_1
&<Common request parameters>

Sample success responses

XML format

<GrantAccountPrivilegeResponse>  
       <RequestId>2FED790E-FB61-4721-8C1C-07C627FA5A19</RequestId>
</GrantAccountPrivilegeResponse>

JSON format

{
	"RequestId":"2FED790E-FB61-4721-8C1C-07C627FA5A19"
}

Error codes

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