Docs Menu
Docs Home
/ /
MongoDB Command Line Interface
/ /

mongocli config

On this page

  • Description
  • Syntax
  • Options
  • Examples

The config command configures the MongoDB CLI to access MongoDB services, including MongoDB Atlas, MongoDB Cloud Manager, and MongoDB Ops Manager. The command groups the settings for accessing the service into a profile.

When you run the command, it prompts you for the following information:

Setting
Description
Necessity
Ops Manager Base URL
URL to access your Ops Manager instance.
Required for Ops Manager access.
Public API Key
Private API Key

Public and Private API key for programmatic access to your project using the MongoDB CLI. For more information on generating these keys, see:

Required.
Default Org ID
ID of your organization.
Optional.
Default Project ID
ID of your project.
Optional.

MongoDB CLI saves these settings as a profile in the MongoDB CLI Configuration File.

mongocli config
[ --profile|-P <profile-name> ]
[ --service cloud|cloud-manager|ops-manager ]

Note

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

Option
Type
Description
Required?
--profile, -P
string
Name for the profile where the access information is saved. If this is omitted, MongoDB CLI saves the access information in a profile named default.
no
--service
string

MongoDB service for which you are configuring MongoDB CLI access. Value can be:

  • cloud - for Atlas

  • cloud-manager - for Cloud Manager

  • ops-manager - for Ops Manager

If this is omitted, defaults to cloud for Atlas.

no

The command does not print any output to the terminal. To verify that the command was successful, you can look for the profile in the mongocli.toml file or use mongocli config describe. If the command returns errors, see Troubleshooting for recommended solutions.

The following examples use the mongocli config command to:

  1. Create a profile for accessing a service.

  2. Save the access information for the service under that profile.

Example 1

The following command saves the access information for Atlas in a profile named default.

~ mongocli config
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Example 2

The following command saves the access information for Atlas in a profile named Profile1.

~ mongocli config --profile Profile1
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Example 1

The following command saves the access information for Cloud Manager in a profile named default.

~ mongocli config --service cloud-manager
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Example 2

The following command saves the access information for Cloud Manager in a profile named Profile1.

~ mongocli config --service cloud-manager --profile Profile1
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Example 1

The following command saves the access information for Ops Manager in a profile named default.

~ mongocli config --service ops-manager
? URL to Access Ops Manager: https://mms.example.com:8080/
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Example 2

The following command saves the access information for Ops Manager in a profile named Profile1.

mongocli config --service ops-manager --profile Profile1
? URL to Access Ops Manager: https://mms.example.com:8080/
? Public API Key: abcdefgh
? Private API Key: [? for help] ************************************
? Choose a default organization: Org1 (5c815cc7d5ec13092a02a1b2)
? Choose a default project: Project1 (5e5ebffd0c04a9700906c3d4)

Back

Configuration