CreateAccount
Creates a database account for a specified ApsaraDB for MongoDB instance and grants one or more database role permissions to the account.
Operation description
Supports cloud disk and local disk instances, and supports replica set and sharded cluster architectures.
Accounts use a non-persistent architecture, and account information is read from the instance in real time. During the transition period before an account is created, the account does not appear in the DescribeAccounts list. After the account is created, it directly appears in the Available state.
The combination of account name and database name (DBName) must be unique within the same instance. Creating a duplicate account is rejected.
The account name cannot use the system reserved name root (case-insensitive) or the reserved prefix __cloud.
The requirement for Roles depends on the instance architecture: it is required for replica set and sharded cluster ConfigServer (cs) accounts. It is prohibited for sharded cluster Shard direct connection (db) accounts (passing it returns InvalidRoles.NotSupported).
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
dds:CreateAccount |
create |
*DBInstance
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DBInstanceId |
string |
Yes |
The instance ID. For a sharded cluster instance, specify the sharded cluster ID. Account operations are executed from the perspective of the ConfigServer. |
dds-uf6e9433e955xxxx |
| AccountName |
string |
Yes |
The account name.
|
admin1 |
| AccountPassword |
string |
Yes |
The account password.
Note
For information about how to handle special characters, see How do I resolve the connection failure caused by special characters in the account name or password of a connection string? |
Test123456! |
| CharacterType |
string |
No |
The account type. Valid values:
|
db |
| Roles |
array<object> |
No |
The list of authorization roles for the account. Required for replica set and ConfigServer (cs) accounts. Prohibited for sharded cluster Shard direct connection (db) accounts.
|
|
|
object |
No |
The authorized role. |
||
| DBName |
string |
No |
The database to which the account belongs (authentication database). |
admin |
| Role |
string |
No |
The role name. It can be a built-in role or a custom role created on the instance. For value rules, see Roles parameter description. |
read |
| DBName |
string |
No |
The database to which the account belongs (authentication database). |
admin |
| AccountDescription |
string |
No |
The account description.
|
test |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
7FEF1BEF-2842-5758-9126-415A297XXXXX |
| TaskId |
integer |
The task ID. |
123456 |
Examples
Success response
JSON format
{
"RequestId": "7FEF1BEF-2842-5758-9126-415A297XXXXX",
"TaskId": 123456
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidAccountName.Malformed | Specified parameter AccountName is not valid. | The specified AccountName parameter is invalid. |
| 400 | InvalidAccountPassword.Malformed | Specified parameter AccountPassword is not valid. | The specified parameter AccountPassword is invalid. |
| 400 | InvalidAccountDescription.Malformed | Specified parameter AccountDescription is not valid. | The specified AccountDescription parameter is invalid. |
| 404 | AccountLimitExceeded | AccountQuotaExceeded: Exceeding the allowed amount of account. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.