Grants a standard account the permissions to access one or more databases in a specified PolarDB cluster.

Note
  • A standard account can be granted the permissions to access one or more databases.
  • If the specified account already has the access permissions on the specified databases, the operation returns a successful response.
  • Before you call this operation, make sure that the cluster is in the Running state. Otherwise, the operation fails.
  • The operation is applicable to only PolarDB for MySQL clusters.
  • By default, a privileged account for a cluster has all the permissions on the databases in the 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

ParameterTypeRequiredExampleDescription
ActionStringNoGrantAccountPrivilege

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

AccountNameStringYestestacc

The name of the account.

AccountPrivilegeStringYesReadWrite,ReadOnly

The account permission. Valid values:

  • ReadWrite: The account has the read and write permissions on the databases.
  • ReadOnly: The account has the read permissions on the databases.
  • DMLOnly: The account has the permissions to execute only data manipulation language (DML) statements on the databases.
  • DDLOnly: The account has the permissions to execute only data definition language (DDL) statements on the databases.
  • ReadIndex: The account has the read and index permissions on the databases.
Note The number of AccountPrivilege values must be the same as the number of DBName values. Each account permission must correspond to a database name in sequence. For example, you can set DBName to testdb_1,testdb_2 and set AccountPrivilege to ReadWrite,ReadOnly. In this case, the specified standard account is granted the read and write permissions on the testdb_1 database and the read permission on the testdb_2 database.
DBClusterIdStringYespc-****************

The ID of the PolarDB cluster.

DBNameStringYestestdb_1,testdb_2

The names of the databases that the account can access. You can grant the access permissions on one or more databases to the specified standard account. If you need to specify multiple database names, separate the database names with commas (,).

Response parameters

ParameterTypeExampleDescription
RequestIdString2FED790E-FB61-4721-8C1C-07C627*****

The ID of the request.

Examples

Sample requests

http(s)://polardb.aliyuncs.com/? Action=GrantAccountPrivilege
&AccountName=testacc
&AccountPrivilege=ReadWrite,ReadOnly
&DBClusterId=pc-****************
&DBName=testdb_1,testdb_2
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

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