调用CreateAccount接口创建管理数据库的账号。
调用该接口时,实例必须满足以下条件,否则将操作失败:
- 实例状态为运行中。
- 数据库状态为运行中。
- 没有超出单个实例内最大账号数量的限制。最大账号数量限制,请参见使用限制。
说明
- 该接口仅适用于MySQL、MariaDB、PostgreSQL、SQL Server(除SQL Server 2017集群版和2019集群版)实例。
- PostgreSQL实例支持多个高权限账号以及多个普通账号。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | CreateAccount | 系统规定参数。取值:CreateAccount。 |
DBInstanceId | String | 是 | rm-uf6wjk5xxxxxxx | 实例ID。可调用DescribeDBInstances获取。 |
AccountName | String | 是 | test1 | 数据库账号名称。 说明
|
AccountPassword | String | 是 | Test123456 | 数据库账号的密码。 说明
|
AccountDescription | String | 否 | 测试账号A | 账号描述,长度为2~256个字符。以中文、英文字母开头,可以包含数字、中文、英文、下划线(_)、短横线(-)。 说明 不能以 http:// 和 https:// 开头。 |
AccountType | String | 否 | Normal | 账号类型,取值:
默认值:Normal。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD | 请求ID。 |
示例
请求示例
http(s)://rds.aliyuncs.com/?Action=CreateAccount
&DBInstanceId=rm-uf6wjk5xxxxxxx
&AccountName=test1
&AccountPassword=Test123456
&<公共请求参数>
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateAccountResponse>
<RequestId>D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD</RequestId>
</CreateAccountResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD"
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | GeneralIns.Creating | The general instance is creating. | 目前有实例还在生产中,请稍等 |
400 | GeneralIns.Maintaining | The general instance is maintaining. | 有实例在迁移或维护中,请稍等 |
400 | GeneralIns.Switching | The general instance is Switching. | HA切换中,请稍等 |
400 | InvalidEngineVersion.NotSupported | Current db instance does not support sysadmin. | 操作失败,当前实例不支持创建sysAdmin帐户。 |
400 | Database.ConnectError | Database connect error. please check instance status and database processlist | 数据库连接异常,请检查实例状态及数据库的连接池 |
400 | Account.AddError | Create Account failed, please check your input value or may your input value not satisfy instance current policy | 添加账户失败, 请检查请求参数或请求的参数不满足实例参数策略配置 |
400 | InvalidAccountPassword.Format | Specified account password is not valid. | 账户密码无效,请重新按照规范设置账户密码。 |
400 | InvalidAccountDescription.Format | Specified account description is not valid. | 无效的账户描述,请重新设置。描述不能为空,且长度不大于256个字符。 |
400 | InvalidGeneralGroupNameOrGdnInstanceName | The specified params generalGroupName or gdnInstanceName should not be null. | 指定的参数generalGroupName或gdInsttanceName不应为空。 |
400 | InvalidAccountPrivilege.Malformed | Specified account privilege is not valid. | 账号权限不足。 |
400 | InvalidAccountName.Forbid | Specified account name is a keyword in RDS. | 账户名不正确,关键字不可用于账户名。请修改账户名。 |
400 | InvalidAccountName.Duplicate | Specified account name already exists in this instance. | 当前账户在实例中已存在,请重新设置账户名。 |
400 | InvalidDBDescription.Format | Specified DB description is not valid. | DB描述不规范,请检查。 |
403 | IncorrectDBInstanceState | Current DB instance state does not support this operation. | 操作失败,该实例状态下不支持此操作。 |
403 | IncorrectAccountType | Current account type does not support this operation. | 当前账户类型不支持此操作,请选择正确的账户类型。 |
403 | AccountLimitExceeded | AccountQuotaExceeded: Exceeding the allowed amount of account | 已超过账号数量的上限。 |
404 | InvalidDBInstanceName.NotFound | The database instance does not exist. | 数据库实例名称不存在。请确认数据名称是否正确。 |
404 | IncorrectDBInstanceLockMode | Current DB instance lock mode does not support this operation. | 操作失败,实例处于锁定状态。 |
访问错误中心查看更多错误码。