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_SKIP_UPDATE_CHECK | When set to yes , the MongoDB CLI does not prompt you to update
to new versions. | ||||||||||
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 IMPORTANT: Setting | ||||||||||
HTTP_PROXY , http_proxy | The absolute URL or the hostname and port in the
The following example shows how to set up the environment variable if your proxy configuration doesn't require authentication.
The following example shows how to set up the environment variable if your proxy configuration requires authentication.
The following example shows how to set up the environment
variable if the scheme is
| ||||||||||
HTTPS_PROXY , https_proxy | The absolute URL. If For example, the following shows how to set up the environment variable.
| ||||||||||
NO_PROXY , no_proxy | Indicates no proxy for the URL because proxy isn't configured
for the URL. |