Navigation

Alpha Release of MongoDB CLI

This is a pre-release early version of MongoDB CLI. Do not use MongoDB CLI to manage production environments.

mongocli ops-manager dbuser create

On this page

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

Syntax

mongocli ops-manager dbuser create
     --username|-u <name-of-user>
     --password|-p <password-of-user>
     --role <name-of-role>
     --mechanisms <authentication-mechanism>
     --authDB <authentication-database>
     [ --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 Ops 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: passW0rd
  • Role: readWrite@test
  • Authentication mechanism: SCRAM-SHA-256

The command uses the profile named omProfile for accessing Ops Manager to create the user.

~ mongocli ops-manager dbuser create --username user1 \
  --password passW0rd \
  --role readWrite@test \
  --mechanisms SCRAM-SHA-256 \
  --profile omProfile

Example 2

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 ops-manager dbuser create --username user2 \
  --password passW0rd \
  --role clusterMonitor,readWriteAnyDatabase \
  --profile omProfile