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 config

Description

The config command configures the MongoDB CLI access to services like MongoDB Atlas, MongoDB Cloud Manager, and MongoDB Ops Manager. The command groups the settings for accessing the service, such as the public and private key, into a named profile.

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

The public and private API keys that you enter are saved as a profile in the mongocli.toml file. This file is in the $HOME/.config directory if $XDG_CONFIG_HOME environment variable is not set. If $XDG_CONFIG_HOME environment variable is set, the mongocli.toml file is in $XDG_CONFIG_HOME directory. You can use this profile for all future access of the service through the MongoDB CLI. To learn more about configuring a profile, see MongoDB CLI Configuration File.

Syntax

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

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 creates a custom profile named egAtlasProfile for accessing Atlas.

mongocli config --service cloud --profilename egAtlasProfile
Public API Key: abcdefgh
Private API Key: [? for help] ************************************

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

mongocli config
Public API Key: abcdefgh
Private API Key: [? for help] ************************************

The following command creates a custom profile named egCMprofile for accessing Cloud Manager.

mongocli config --service cloud-manager --profilename egCMprofile
Public API Key: abcdefgh
Private API Key: [? for help] ************************************

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

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