Call the GrantDBAccountPrivilege API to grant database privileges to a specified database account.
Synchronous request.
Name | Type | Required | Example | Description |
|---|---|---|---|---|
InstanceId | String | Yes | mysql-62e07c2c**** | Instance ID. |
AccountName | String | Yes | testuser | Account name. |
Host | String | No | % | The IP address from which the account accesses the database. Default value: %. |
AccountPrivileges | Object[] | Yes | [
{
"DBName":"db1",
"AccountPrivilege":"ReadWrite"
}
] | Reset account authorization information. |
AccountPrivilege | String | Yes | ReadWrite | The type of database privilege. Valid values:
tip When used as a request parameter, note the following:
|
AccountPrivilegeDetail | String | No | SELECT,INSERT,UPDATE | The privilege information of the account.
tip
|
DBName | String | Yes | testdb1 | The name of the database for which the account authorization needs to be modified or for which the account already has permissions. tip
|
DryRun | Boolean | No | true | Whether to retrieve the SQL statements for granting privileges to the account. Valid values:
tip When the value is |
TableColumnPrivileges | Object[] | No | Refer to the request example. | Column-level privilege settings for the account. |
DBName | String | Yes | TestDatabase | The name of the database to which the table for account permission settings belongs. |
TablePrivileges | Object[] | No | Please refer to the request example. | The table permission information of the account. |
TableName | String | Yes | TestTable | The name of the table for setting account permissions. |
AccountPrivilegeDetail | String | No | "ALTER,CREATE" | Table permissions for the account. Valid values (multiple selections allowed):
tip Separate multiple permissions with English commas (,). |
ColumnPrivileges | Object[] | No | Please refer to the request example. | The column permission information of the account. |
TableName | String | Yes | Table1 | The name of the database to which the table with column-level permissions for the account belongs. |
ColumnName | String | Yes | Column1 | The name of the column for which column-level permissions are set for the account. |
AccountPrivilegeDetail | String | No | "UPDATE,INSERT" | The permission information for column-level permissions set for the account. Valid values (multiple selections allowed):
tip Separate multiple permissions with English commas (,). |
Name | Type | Example | Description |
|---|---|---|---|
GrantPrivilegeSQL | String[] | [
"REVOKE ALL PRIVILEGES ON `t1`.* FROM TestAccount@'%';",
"GRANT SELECT,LOCK TABLES,SHOW VIEW ON `t1`.* TO TestAccount@'%';"
] | The SQL statement used to grant privileges to the account based on the request parameters. Returned when DryRun is set to true. |
POST /?Action=GrantDBAccountPrivilege&Version=2022-01-01 HTTP/1.1 Content-Type: application/json Host: rds-mysql.cn-beijing.volcengineapi.com X-Date: 20211202T101010Z Authorization: HMAC-SHA256 Credential=AKLTN2I0MmFiNzMxNWE5NDgzMzk4MmVjMTVkODlkZTZ****/20211202/cn-beijing/rds_mysql/request,SignedHeaders=x-date, Signature=71d31fc7bcf990142851c9833c5656391486cda0ae2e0b8ada733b7c6458**** { "InstanceId": "mysql-62e07c2c****", "AccountName": "test", "AccountPrivileges": [ { "DBName": "testdb", "AccountPrivilege": "DDLOnly", "AccountPrivilegeDetail": "" }, { "DBName": "testdb1", "AccountPrivilege": "ReadOnly", "AccountPrivilegeDetail": "" } ] }
{ "ResponseMetadata": { "RequestId": "20230116115015A96C208EE46C00F7D56B", "Action": "GrantDBAccountPrivilege", "Version": "2022-01-01", "Service": "rds_mysql", "Region": "cn-beijing" }, "Result": null }
For more details, refer to Error codes.