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
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | No | GrantAccountPrivilege | The operation that you want to perform. Set the value to GrantAccountPrivilege. |
AccountName | String | Yes | testacc | The name of the account. |
AccountPrivilege | String | Yes | ReadWrite,ReadOnly | The account permission. Valid values:
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. |
DBClusterId | String | Yes | pc-**************** | The ID of the PolarDB cluster. |
DBName | String | Yes | testdb_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
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 2FED790E-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.