Environment Variables
On this page
For easier scripting, you can specify configuration settings by using environment variables.
Precedence
When you run a command, any settings that you specified with environment variables take precedence over the profile stored in the configuration file.
When you run a command using the
--projectId
option, the command line option takes precedence over both the environment variable and the profile stored in the configuration file.
Supported Environment Variables
The MongoDB CLI supports the following environment variables:
Variable | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MCLI_PUBLIC_API_KEY | Sets the public API key for commands that interact with your
MongoDB service. | ||||||||||
MCLI_PRIVATE_API_KEY | Sets the private API key for commands that interact with your
MongoDB service. | ||||||||||
MCLI_ORG_ID | Sets the organization ID for commands that require the
--orgId option. | ||||||||||
MCLI_PROJECT_ID | Sets the project ID for commands that require the --projectId
option. | ||||||||||
MCLI_OPS_MANAGER_URL | For Ops Manager only, sets the base URL for API calls. The
URL must end with a forward slash (i.e. / ). | ||||||||||
MCLI_SERVICE | Sets the MongoDB service type. Valid values are:
| ||||||||||
MCLI_OUTPUT | Sets the output fields and format. Valid values are:
| ||||||||||
MCLI_MONGOSH_PATH | The full path on your local system to the MongoDB Shell,
mongosh . | ||||||||||
MCLI_OPS_MANAGER_CA_CERTIFICATE Ops Manager only | If applicable, the full path on your local
system to the PEM-encoded Certificate Authority (CA) certificate
used to sign the client and Ops Manager TLS certificates. | ||||||||||
MCLI_OPS_MANAGER_SKIP_VERIFY Ops Manager only | When set to ImportantSetting |