You can call this operation to grant privileges to an RDS database account so that it can access one or more databases.

When you call this operation, the instance must be in the running state.

Note This operation is not applicable to SQL Server 2017 Cluster Edition, PostgreSQL, and PPAS instances.

Debugging

You can use OpenAPI Explorer to perform debugging.

OpenAPI Explorer provides various functions to simplify API usage. For example, you can retrieve APIs, call APIs, and generate SDK sample code.

Request parameters

Parameter Type Required Example Description
Action String Yes GrantAccountPrivilege

The operation that you want to perform. Set this parameter 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 that the account needs to access.

AccountPrivilege String Yes ReadWrite

The account privilege. Valid values:

  • ReadWrite
  • ReadOnly
  • DDLOnly: This value is only for MySQL and MariaDB.
  • DMLOnly: This value is only for MySQL and MariaDB.
  • DBOwner: This value is only for SQL Server.

Response parameter

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

The ID of the request.

Examples

Request example


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

Normal response examples

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.