Navigation

mongocli config

Description

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 named profile.

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

Setting Description Necessity
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.
Project ID ID of your project. Optional.
Ops Manager Base URL URL of the Ops Manager instance. Required for Ops Manager access.

MongoDB CLI saves these settings as a profile in the mongocli.toml configuration file.

If the $XDG_CONFIG_HOME environment variable is not set, this file is located in the $HOME/.config directory. If the $XDG_CONFIG_HOME environment variable is set, the mongocli.toml file is in the directory specified in $XDG_CONFIG_HOME. You can then use this profile to access the service through the MongoDB CLI. To learn more about configuring a profile, see MongoDB CLI Configuration File.

Syntax

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.

Options

Option Type Description Required?
--profile, -P string Name for the profile where the access information is saved. If this is omitted, the access information is saved as the default profile. 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

Output

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. If the command returns errors, see Troubleshooting for recommended solutions.

Examples

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.

The following commands show different ways to create a profile for accessing Atlas.

Example 1

The following command saves the access keys for Atlas in the default profile.

mongocli config
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c

Example 2

The following command creates a custom profile named egAtlasProfile for accessing Atlas.

mongocli config --profile egAtlasProfile
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c

Example 1

The following command saves the access keys for Cloud Manager in the default profile.

mongocli config --service cloud-manager
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c

Example 2

The following command creates a custom profile named egCMProfile for accessing Atlas.

mongocli config --service cloud-manager --profile egCMProfile
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c

Example 1

The following command saves the access keys for Ops Manager in the default profile.

mongocli config --service ops-manager
Ops Manager Base URL: http://om-svc.mongodb.svc.cluster.local:8080
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c

Example 2

The following command creates a custom profile named egOMprofile for accessing Ops Manager.

mongocli config --service ops-manager --profile egOMprofile
Ops Manager Base URL: http://om-svc.mongodb.svc.cluster.local:8080
Public API Key: abcdefgh
Private API Key: [? for help]
************************************
Project ID [optional]: 7ehf04abc10defb66c7d1234c