Select your preferred Version and OS from the dropdowns.
Shellfrom the Package dropdown and click Download to start downloading the package.
Shelloption is unavailable for the selected OS and Version, contact MongoDB Technical Support for assistance.
Starting in MongoDB 3.6.15, the
mongo shell displays a warning message when connected to non-genuine MongoDB instances as these instances may behave differently from the official MongoDB instances; e.g. missing or incomplete features, different feature behaviors, etc.
--shelloption provides the user with a shell prompt after the file finishes executing.
Prevents the shell from connecting to any database instances. Later, to connect to a database within the shell, see Opening New Connections.
To connect to a replica set, specify the
replica set nameand a seed list of set members. Use the following form:
For TLS/SSL connections (
--ssl), mongo verifies that the hostname of the
mongosto which you are connecting matches the CN or SAN of the
--sslPEMKeyFilecertificate. If the hostname does not match the CN/SAN, mongo will fail to connect.
For DNS seedlist connections , specify the connection protocol as
mongodb+srv, followed by the DNS SRV hostname record and any options. The
replicaSetoptions, if included in the connection string, will override any corresponding DNS-configured options set in the TXT record. Use of the
mongodb+srv:connection string implicitly enables TLS/SSL (normally set with
ssl=true) for the client connection. The TLS/SSL option can be turned off by setting
ssl=falsein the query string.
New in version 3.6.
Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the
--authenticationDatabaseoptions. To force mongo to prompt for a password, enter the
--passwordoption as the last option and leave out the argument.
New in version 3.4.
Enables network compression for communication between this mongo shell and:
You can specify the following compressors:
Messages are compressed when both parties enable network compression. Otherwise, messages between the parties are uncompressed.
If you specify multiple compressors, then the order in which you list the compressors matter as well as the communication initiator. For example, if a
mongoshell specifies the following network compressors
snappy,zlib, messages between
If the parties do not share at least one common compressor, messages between the parties are uncompressed. For example, if a
mongoshell specifies the network compressor
snappy, messages between
mongodare not compressed.
Enables IPv6 support. mongo disables IPv6 by default.
mongosdisable IPv6 support by default. Specifying
--ipv6when connecting to a
mongod/mongosdoes not enable IPv6 support on the
mongod/mongos. For documentation on enabling IPv6 support on the
Specifies the name of the database to connect to. For example:
The above command will connect the mongo shell to the admin database of the MongoDB deployment running on the local machine. You may specify a remote database instance, with the resolvable hostname or IP address. Separate the database name from the hostname using a
/character. See the following examples:
This syntax is the only way to connect to a specific database.
New in version 3.4.
The default behavior (when
mongostarts without the
Code. The following example demonstrates the default behavior within the shell: