Navigation

mongocli cloud-manager dbuser create

On this page

The dbuser create command creates a MongoDB database user to access the specified Cloud Manager clusters in the given project. You can also create a MongoDB database user through the Cloud Manager UI.

Syntax

mongocli cloud-manager dbuser create
     --username|-u <name-of-user>
     --password|-p <password-of-user>
     --role <name-of-role>
     --mechanisms <authentication-mechanism>
     --authDB
     [ --profile|-P <profile-name> ]
     [ --projectId <project-ID> ]

Note

Use -h or --help to view the command-line help for this command.

Options

Option Type Description Required?
--username, -u string Username for authenticating the user to MongoDB. yes
--password, -p string Password for authenticating the user to MongoDB. yes
--role string or list of strings

Comma-separated list of user’s roles and the databases or collections on which the roles apply. A role allows the user to perform particular actions on the specified database or collection. You can also include multiple --role flags in a single mongocli command to specify multiple roles for a user.

To learn more about the list of default roles, see Built-In Roles.

yes
--mechanisms string or list of strings Comma-separated list of authentication mechanisms enabled for this user. Defaults to SCRAM-SHA-1. no
--authDB string Name of the authentication database. Defaults to admin. no
--profile, -P string Name of the profile where the public and private keys for the project are saved. If omitted, uses the default profile. To learn more about creating a profile, see Configure the MongoDB CLI. no
--projectId string Unique identifier of the project that contains the cluster. If omitted, uses the project ID in the profile or environment variable. no

Output

A successful dbuser create command returns an in-progress status message with a link to your Cloud Manager topology page.

Examples

The examples below use the mongocli cloud-manager dbuser create command to create a MongoDB database user. In each example, the projectId is listed in the configuration file.

Example 1

The following command creates a user with the following attributes:

  • Username: user1
  • Password: ChangeThisToAStrongPassword
  • Role: readWrite@test
  • Authentication mechanism: SCRAM-SHA-256

The command uses the default profile to access Cloud Manager to create the user.

mongocli cloud-manager dbuser create --username user1 \
  --password ChangeThisToAStrongPassword \
  --role readWrite@test \
  --mechanisms SCRAM-SHA-256

Example 2

The following commands show two ways to create a user with readWriteAnyDatabase and clusterMonitor privileges. The command uses the default profile to access the project, which contains the API keys and project ID for accessing Atlas.

The following command shows the --role option with two roles separated by a comma. The new user has the default SCRAM-SHA-1 authentication mechanism enabled.

mongocli cloud-manager dbuser create --username user2 \
  --password ChangeThisToAStrongPassword \
  --role clusterMonitor,readWriteAnyDatabase

The following command specifies the --role option twice, once for each privilege.

mongocli cloud-manager dbuser create --username user2 \
  --password ChangeThisToAStrongPassword \
  --role clusterMonitor \
  --role readWriteAnyDatabase