You can call the CreateAccount operation to create an account that is used to manage databases on an ApsaraDB RDS instance.
Before you call this operation, make sure that the following requirements are met:
- The instance is in the Running state.
- The database is in the running state.
- The number of accounts that are created on the instance does not exceed the maximum number of accounts for an instance. For more information about the maximum number of accounts, see Limits.
- This operation is supported for instances that run MySQL, MariaDB, PostgreSQL, and SQL Server. However, if the instance runs SQL Server 2017 or SQL Server 2019 on RDS Cluster Edition, this operation is not supported.
- You can create multiple privileged accounts and multiple standard accounts for each ApsaraDB RDS instance that runs PostgreSQL.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | CreateAccount | The operation that you want to perform. Set the value to CreateAccount. |
| DBInstanceId | String | Yes | rm-uf6wjk5xxxxxxx | The ID of the instance. You can call the DescribeDBInstances operation to query the ID of the instance. |
| AccountName | String | Yes | test1 | The username of the account. Note
|
| AccountPassword | String | Yes | Test123456 | The password of the account. Note
|
| AccountDescription | String | No | Test account A | The description of the account. The description must be 2 to 256 characters in length and can contain letters, digits, underscores (_), and hyphens (-). The description must start with a letter. Note The description cannot start with http:// or https://. |
| AccountType | String | No | Normal | The type of the account. Valid values:
Default value: Normal. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| RequestId | String | D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD | The ID of the request. |
Examples
Sample requests
http(s)://rds.aliyuncs.com/?Action=CreateAccount
&DBInstanceId=rm-uf6wjk5xxxxxxx
&AccountName=test1
&AccountPassword=Test123456
&<Common request parameters>Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateAccountResponse>
<RequestId>D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD</RequestId>
</CreateAccountResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD"
}Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | GeneralIns.Creating | The general instance is creating. | The error message returned because an instance is being created. Try again later. |
| 400 | GeneralIns.Maintaining | The general instance is maintaining. | The error message returned because an instance is being migrated or maintained. Try again later. |
| 400 | GeneralIns.Switching | The general instance is Switching. | The error message returned because a primary/secondary switchover is being performed to ensure high availability. Try again later. |
| 400 | InvalidEngineVersion.NotSupported | Current db instance does not support sysadmin. | The error message returned because the current instance does not support the creation of a sysAdmin account for the instance. |
| 400 | Database.ConnectError | Database connect error. please check instance status and database processlist | The error message returned because the database connection is abnormal. Check the instance status and the connection pool of the database. |
| 400 | Account.AddError | Create Account failed, please check your input value or may your input value not satisfy instance current policy | The error message returned because the account fails to be created. Check whether the request parameters or requested parameters meet the requirements for parameter configurations. |
For a list of error codes, visit the API Error Center.