mongosh [Connection String]

The MongoDB Shell, mongosh is a fully functional JavaScript and Node.js 14.x REPL environment for interacting with MongoDB deployments

Arguments

NameDescription
Connection String

Options

NameDescription
-v, --versionView your current mongosh version
--shellEnables the shell interface. If you invoke the mongosh command and specify a JavaScript file as an argument, or use --eval to specify JavaScript on the command line, the --shell option provides the user with a shell prompt after the file finishes executing
--eval <javascript>Evaluates a JavaScript expression that is specified as an argument. mongosh does not load its own environment when evaluating code. As a result many options of the shell environment are not available. The result of evaluating a JavaScript argument is printed to your command line
--help, -hReturns information on the options and use of the MongoDB Shell
--authenticationDatabase <dbname>Specifies the authentication database where the specified --username has been created. See Authentication Database
--gssapiHostName <hostname>Specify the hostname of a service using GSSAPI/Kerberos. Only required if the hostname of a machine does not match the hostname resolved by DNS
--gssapiServiceName <saslServiceName>Specify the name of the service using GSSAPI/Kerberos. Only required if the service does not use the default name of mongodb
--password, -p <password>Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --username and --authenticationDatabase options
--username, -u <username>Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the --password and --authenticationDatabase options
--retryWritesEnables retryable writes as the default for sessions in the MongoDB Shell
--authenticationMechanism <authentication mechanism>Specifies the authentication mechanism the MongoDB Shell uses to authenticate to the mongod or mongos
--nodbPrevents the shell from connecting to any database instances
--norcPrevents the shell from sourcing and evaluating ~/.mongoshrc.js on startup
--quietSkips all messages during startup (such as welcome messages and startup warnings) and goes directly to the prompt
--verboseIncreases the verbosity of the shell output during the connection process and when running commands
--port <port>Specifies the port where the mongod or mongos instance is listening. If --port is not specified, the MongoDB Shell attempts to connect to port 27017
--tlsEnables connection to a mongod or mongos that has TLS SSL support enabled
--tlsAllowInvalidHostnamesDisables the validation of the hostnames in the certificate presented by the mongod/mongos instance. Allows the MongoDB Shell to connect to MongoDB instances even if the hostname in the server certificates do not match the server's host
--tlsAllowInvalidCertificatesBypasses the validation checks for the certificates presented by the mongod/mongos instance and allows connections to servers that present invalid certificates
--tlsDisabledProtocols <protocols>Disables the specified TLS protocols
--tlsCAFile <filePath>Specifies the .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance
--tlsCRLFile <filePath>Specifies the .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance
--tlsCertificateKeyFile <filePath>Enables connection to a mongod or mongos that has TLS SSL support enabled