Grants an account access to a database in an ApsaraDB for RDS instance.

An account can be granted access to one or more databases. Before you call this operation, make sure that the RDS instance is in the Running state.

Note This operation is not supported for SQL Server 2017 in the Cluster Edition, PostgreSQL with local SSDs, or PPAS.

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 Yes GrantAccountPrivilege

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

DBInstanceId String Yes rm-uf6wjk5xxxxxxxxxx

The ID of the instance.

AccountName String Yes test1

The name of the account.

DBName String Yes testDB

The name of the database to which you want to grant access.

AccountPrivilege String Yes ReadWrite

The permissions that you want to grant to the account. Valid values:

  • ReadWrite: the read/write permission.
  • ReadOnly: the read/only permission.
  • DDLOnly: the permission only to execute data definition language (DDL) operations. This option is only available to MySQL and MariaDB.
  • DMLOnly: the permission only to execute data manipulation language (DML) operations. This option is only available to MySQL and MariaDB.
  • DBOwner: the database owner who has all permissions on the database. This option is available to SQL Server and PostgreSQL with standard SSDs or enhanced SSDs (ESSDs).

Response parameters

Parameter Type Example Description
RequestId String 81BC9559-7B22-4B7F-B705-5F56DEECDEA7

The ID of the instance.

Examples

Sample requests


http(s)://rds.aliyuncs.com/? Action=GrantAccountPrivilege
&DBInstanceId=rm-uf6wjk5xxxxxxx
&AccountName=test1
&DBName=test
&AccountPrivilege=ReadWrite
&<Common request parameters>

Sample success responses

XML format

<GrantAccountPrivilegeResponse>
	  <RequestId>81BC9559-7B22-4B7F-B705-5F56DEECDEA7</RequestId></GrantAccountPrivilegeResponse>

JSON format

{
	"RequestId":"81BC9559-7B22-4B7F-B705-5F56DEECDEA7"
}

Error codes

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