When you create an ApsaraDB for MongoDB instance, the system automatically creates a root account in the admin database. The permissions granted to this root account depend on the MongoDB version your instance runs.
| Instance version | Role assigned to root account |
|---|---|
| MongoDB 4.2 and earlier | Built-in root role |
| MongoDB 4.4 or later | alibabaCloudAdmin role (Alibaba Cloud custom role) |
To check what the root account can do, run:
db.getSiblingDB("admin").runCommand({usersInfo: "root"});
For details on the usersInfo command, see usersInfo.
To inspect a specific role's permissions, use the rolesInfo command. For the built-in root role, see root.
For data security, avoid using the root account for day-to-day database operations. Instead, create a dedicated database account with only the permissions your workload requires. See Create an account for an ApsaraDB for MongoDB instance.
Permissions of the alibabaCloudAdmin role
The alibabaCloudAdmin role is a custom role for ApsaraDB for MongoDB. It differs from the standard root role — understanding these differences helps you avoid unexpected permission errors.
Included built-in roles
The alibabaCloudAdmin role combines the following MongoDB built-in roles:
| Built-in role | Capabilities |
|---|---|
readWriteAnyDatabase |
Read and write collections in any database |
userAdminAnyDatabase |
Manage accounts in any database |
dbAdminAnyDatabase |
Query statistics and manage indexes in any database |
clusterMonitor |
Read-only access to monitoring tools |
backup |
Perform backup operations |
enableSharding |
Enable sharding on a database |
restore |
Restore data from backups |
Admin database restriction
The alibabaCloudAdmin role has read-only access to the admin database. It cannot write to the admin database, and it cannot create accounts with write permissions on the admin database.
In some scenarios, severe performance jitter may occur when you write data to the admin database. As a result, you cannot create users or roles with readWrite, dbAdmin, or dbOwner permissions scoped to the admin database.
Differences from standard MongoDB behavior
ApsaraDB for MongoDB's xxxAnyDatabase permissions (such as readWriteAnyDatabase) do not cover the config, local, and admin databases. In standard MongoDB, these roles include all databases. Keep this in mind when granting permissions for operations that touch these system databases.
Sharded cluster O&M commands
For sharded cluster instances, the root account with alibabaCloudAdmin can run the following O&M commands directly:
flushRouterConfig, cleanupOrphaned, runCommandOnShard, splitVector, clearJumboFlag, moveChunk, splitChunk