Docs Menu

Docs HomeLaunch & Manage MongoDBMongoDB CLI

Configure the MongoDB CLI

On this page

  • Prerequisites
  • Procedure
  • Next Steps

You can define the settings that the MongoDB CLI uses to interact with MongoDB services like Atlas, Cloud Manager, and Ops Manager by using the mongocli auth login or mongocli config command. The first time you run one of these commands, the MongoDB CLI creates a configuration file called config.toml to store your settings.

To configure the MongoDB CLI:

  • Add your IP or CIDR block to the API access list for your MongoDB service.

  • Generate a Programmatic API Key if you don't already have one.

    Note

    Programmatic API Keys are role-based. Different roles have different privileges and capabilities, and some MongoDB CLI commands are available to some roles but not others. Be sure that the roles assigned to your Programmatic API Key are appropriate for the commands you intend to use.

    To learn more about generating a Programmatic API Key for your MongoDB service, see the following documentation:

    • Atlas API Access

    • Cloud Manager API Access

    • Ops Manager API Acess

  • Set up the HTTP_PROXY or HTTPS_PROXY environment variable if your MongoDB CLI installation is behind a firewall and you want to use a proxy URL. MongoDB CLI supports http, https, and socks5 schemes. In addition, specify cloud.mongodb.com/ as the main target URL in the proxy service's access list. You must specify the username and password also if your proxy configuration enables authentication.

    To learn more, see Proxy server.

←  Install or Update the MongoDB CLIMongoDB CLI Configuration File →