OS Manuals

/usr/bin/mongosh

The MongoDB Shell

From mongosh 2.14.1-r0 (extra-packages), captured 2026-11-05 by running mongosh --help (exit 0). permalink

  $ mongosh [options] [db address] [file names (ending in .js or .mongodb)]

  Options:

    -h, --help                                 Show this usage information
    -f, --file [arg]                           Load the specified mongosh script
        --host [arg]                           Server to connect to
        --port [arg]                           Port to connect to
        --build-info                           Show build information
        --version                              Show version information
        --quiet                                Silence output from the shell during the connection process
        --shell                                Run the shell after executing files
        --nodb                                 Don't connect to mongod on startup - no 'db address' [arg] expected
        --norc                                 Will not run the '.mongoshrc.js' file on start up
        --eval [arg]                           Evaluate javascript
        --json[=canonical|relaxed]             Print result of --eval as Extended JSON, including errors
        --retryWrites[=true|false]             Automatically retry write operations upon transient network errors (Default: true)
        --deep-inspect[=true|false]           Force full depth inspection of server results (default: true if in interactive mode)

  Authentication Options:

    -u, --username [arg]                       Username for authentication
    -p, --password [arg]                       Password for authentication
        --authenticationDatabase [arg]         User source (defaults to dbname)
        --authenticationMechanism [arg]        Authentication mechanism
        --awsIamSessionToken [arg]             AWS IAM Temporary Session Token ID
        --gssapiServiceName [arg]              Service name to use when authenticating using GSSAPI/Kerberos
        --sspiHostnameCanonicalization [arg]   Specify the SSPI hostname canonicalization (none or forward, available on Windows)
        --sspiRealmOverride [arg]              Specify the SSPI server realm (available on Windows)

  TLS Options:

        --tls                                  Use TLS for all connections
        --tlsCertificateKeyFile [arg]          PEM certificate/key file for TLS
        --tlsCertificateKeyFilePassword [arg]  Password for key in PEM file for TLS
        --tlsCAFile [arg]                      Certificate Authority file for TLS
        --tlsAllowInvalidHostnames             Allow connections to servers with non-matching hostnames
        --tlsAllowInvalidCertificates          Allow connections to servers with invalid certificates
        --tlsCertificateSelector [arg]         TLS Certificate in system store (Windows and macOS only)
        --tlsCRLFile [arg]                     Specifies the .pem file that contains the Certificate Revocation List
        --tlsDisabledProtocols [arg]           Comma separated list of TLS protocols to disable [TLS1_0,TLS1_1,TLS1_2]
        --tlsFIPSMode                          Enable the system TLS library's FIPS mode

  API version options:

        --apiVersion [arg]                     Specifies the API version to connect with
        --apiStrict                            Use strict API version mode
        --apiDeprecationErrors                 Fail deprecated commands for the specified API version

  FLE Options:

        --awsAccessKeyId [arg]                 AWS Access Key for FLE Amazon KMS
        --awsSecretAccessKey [arg]             AWS Secret Key for FLE Amazon KMS
        --awsSessionToken [arg]                Optional AWS Session Token ID
        --keyVaultNamespace [arg]              database.collection to store encrypted FLE parameters
        --kmsURL [arg]                         Test parameter to override the URL of the KMS endpoint

  OIDC auth options:

        --oidcFlows[=auth-code,device-auth]    Supported OIDC auth flows
        --oidcRedirectUri[=url]                Local auth code flow redirect URL [http://localhost:27097/redirect]
        --oidcTrustedEndpoint                  Treat the cluster/database mongosh as a trusted endpoint
        --oidcIdTokenAsAccessToken             Use ID tokens in place of access tokens for auth
        --oidcDumpTokens[=mode]                Debug OIDC by printing tokens to mongosh's output [redacted|include-secrets]
        --oidcNoNonce                          Don't send a nonce argument in the OIDC auth request

  DB Address Examples:

        foo                                    Foo database on local machine
        192.168.0.5/foo                        Foo database on 192.168.0.5 machine
        192.168.0.5:9999/foo                   Foo database on 192.168.0.5 machine on port 9999
        mongodb://192.168.0.5:9999/foo         Connection string URI can also be used

  File Names:

        A list of files to run. Files must end in .js and will exit after unless --shell is specified.

  Examples:

        Start mongosh using 'ships' database on specified connection string:
        $ mongosh mongodb://192.168.0.5:9999/ships

  For more information on usage: https://mongodb.com/docs/mongodb-shell.
Options (46)
OptionDescriptionSource
-h, --helpShow this usage informationhelp
-f, --file argLoad the specified mongosh scripthelp
--host argServer to connect tohelp
--port argPort to connect tohelp
--build-infoShow build informationhelp
--versionShow version informationhelp
--quietSilence output from the shell during the connection processhelp
--shellRun the shell after executing fileshelp
--nodbDon't connect to mongod on startup - no 'db address' [arg] expectedhelp
--norcWill not run the '.mongoshrc.js' file on start uphelp
--eval argEvaluate javascripthelp
--json canonical|relaxedPrint result of --eval as Extended JSON, including errorshelp
--retryWrites true|falseAutomatically retry write operations upon transient network errors (Default: true)help
--deep-inspect true|falseForce full depth inspection of server results (default: true if in interactive mode)help
-u, --username argUsername for authenticationhelp
-p, --password argPassword for authenticationhelp
--authenticationDatabase argUser source (defaults to dbname)help
--authenticationMechanism argAuthentication mechanismhelp
--awsIamSessionToken argAWS IAM Temporary Session Token IDhelp
--gssapiServiceName argService name to use when authenticating using GSSAPI/Kerberoshelp
--sspiHostnameCanonicalization argSpecify the SSPI hostname canonicalization (none or forward, available on Windows)help
--sspiRealmOverride argSpecify the SSPI server realm (available on Windows)help
--tlsUse TLS for all connectionshelp
--tlsCertificateKeyFile argPEM certificate/key file for TLShelp
--tlsCertificateKeyFilePassword argPassword for key in PEM file for TLShelp
--tlsCAFile argCertificate Authority file for TLShelp
--tlsAllowInvalidHostnamesAllow connections to servers with non-matching hostnameshelp
--tlsAllowInvalidCertificatesAllow connections to servers with invalid certificateshelp
--tlsCertificateSelector argTLS Certificate in system store (Windows and macOS only)help
--tlsCRLFile argSpecifies the .pem file that contains the Certificate Revocation Listhelp
--tlsDisabledProtocols argComma separated list of TLS protocols to disable [TLS1_0,TLS1_1,TLS1_2]help
--tlsFIPSModeEnable the system TLS library's FIPS modehelp
--apiVersion argSpecifies the API version to connect withhelp
--apiStrictUse strict API version modehelp
--apiDeprecationErrorsFail deprecated commands for the specified API versionhelp
--awsAccessKeyId argAWS Access Key for FLE Amazon KMShelp
--awsSecretAccessKey argAWS Secret Key for FLE Amazon KMShelp
--awsSessionToken argOptional AWS Session Token IDhelp
--keyVaultNamespace argdatabase.collection to store encrypted FLE parametershelp
--kmsURL argTest parameter to override the URL of the KMS endpointhelp
--oidcFlows auth-codeSupported OIDC auth flowshelp
--oidcRedirectUri urlLocal auth code flow redirect URL [http://localhost:27097/redirect]help
--oidcTrustedEndpointTreat the cluster/database mongosh as a trusted endpointhelp
--oidcIdTokenAsAccessTokenUse ID tokens in place of access tokens for authhelp
--oidcDumpTokens modeDebug OIDC by printing tokens to mongosh's output [redacted|include-secrets]help
--oidcNoNonceDon't send a nonce argument in the OIDC auth requesthelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.