调用GrantAccountPrivilege接口授权账号访问数据库。
一个账号可授权访问一个或多个数据库。调用该接口时,请确保实例状态为运行中,否则将操作失败。
说明 该接口暂不支持SQL Server 2017集群版、PostgreSQL本地盘版。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | GrantAccountPrivilege |
系统规定参数。取值:GrantAccountPrivilege。 |
DBInstanceId | String | 是 | rm-uf6wjk5xxxxxxxxxx |
实例ID。 |
AccountName | String | 是 | test1 |
账号名称。 |
DBName | String | 是 | testDB1 |
需要授权访问的数据库名称,多个数据库名称之间用英文逗号(,)分隔。 |
AccountPrivilege | String | 是 | ReadWrite |
账号权限,填了多少个DBName值,就需要填多少个该参数值。取值含义:
说明
|
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | 81BC9559-7B22-4B7F-B705-5F56DEECDEA7 |
请求ID。 |
示例
请求示例
http(s)://rds.aliyuncs.com/?Action=GrantAccountPrivilege
&DBInstanceId=rm-uf6wjk5xxxxxxxxxx
&AccountName=test1
&DBName=testDB1
&AccountPrivilege=ReadWrite
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<?xml version="1.0" encoding="UTF-8" ?>
<GrantAccountPrivilegeResponse>
<RequestId>81BC9559-7B22-4B7F-B705-5F56DEECDEA7</RequestId>
</GrantAccountPrivilegeResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "81BC9559-7B22-4B7F-B705-5F56DEECDEA7"
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | Account.UpdateError | Update Account failed, please check your input value | 更新账户失败, 请检查请求参数,或实例参数策略配置 |
400 | Database.ConnectError | Database connect error. please check instance status and database processlist | 数据库连接异常,请检查实例状态及数据库的连接池 |
400 | DbRestoring | Database is in restoring state. | 数据库处于还原状态。 |
400 | InvalidAccountPrivilege.Malformed | Specified account privilege is not valid. | 账号权限不足。 |
400 | IncorrectAccountStatus | Current account status does not support this operation. | 当前账号状态不支持此操作。 |
400 | IncorrectAccount | Current DB instance account does not support this operation. | 当前实例账号不支持此操作。 |
403 | IncorrectDBInstanceType | Current DB instance type does not support this operation. | 操作失败,该实例状态下不支持此操作。 |
403 | IncorrectDBInstanceState | Current DB instance state does not support this operation. | 操作失败,该实例状态下不支持此操作。 |
403 | IncorrectAccountType | Current account type does not support this operation. | 当前账户类型不支持此操作,请选择正确的账户类型。 |
403 | IncorrectAccountPrivilegeType | the current account privilege type does not support this operation. | 当前账户权限类型不支持此操作 |
403 | OperationDenied.AccountMode | The operation is not permitted due to account mode of instance. | 操作失败,当前实例的帐户模式不支持此操作。 |
403 | IncorrectDBInstanceCharacterType | Current DB Instance character_type does not support this operation. | 当前DB实例字符类型不支持此操作。 |
404 | IncorrectDBInstanceLockMode | Current DB instance lock mode does not support this operation. | 操作失败,实例处于锁定状态。 |
404 | InvalidAccountName.NotFound | Specified account name does not exist. | 当前账户名不存在,请确认或选择正确的账户名。 |
访问错误中心查看更多错误码。