mongocli ops-manager dbuser create
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> [ --output|-o <output-format> ] [ --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 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 |
--output , -o | string | Command output format. Valid values are:
If omitted, the command returns output in the default format. | 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. 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:
ChangeThisToAStrongPassword
Role:
readWrite@test
Authentication mechanism:
SCRAM-SHA-256
The command uses the default profile to access
Ops Manager
to create the user.
mongocli ops-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 ops-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