Fix This Page
Navigation

Connect via mongo Shell

The Connect dialog for a cluster provides the details to connect to a cluster via the mongo shell. To connect using the mongo,

  • For MongoDB 3.2 clusters, use the 3.2.6 or later version with TLS/SSL support.
  • For MongoDB 3.4 clusters, use the 3.4 version mongo shell with TLS/SSL support.

If you do not have the appropriate version of the mongo shell, you can download it from the Connect dialog. You can also download the Server package, which includes the mongo shell, from the Download Center [1].

[1]If downloading the version 3.2.6 Server package for OSX, do not use homebrew to install the the package for use with Atlas; instead, download the *.tgz or *.zip file.

Prerequisites

  • TLS/SSL

    Clients must have support for TLS/SSL to connect to an Atlas cluster.

    Clients must have support for the SNI TLS extension to connect to an Atlas M0 Free Tier cluster.

  • Whitelist

    To access a cluster, you must connect from an IP address on the Atlas group’s IP whitelist. If you need to add an IP address to the whitelist, you can do so in the Connect dialog. You can also add the IP address from the Security tab.

Connect to Your Cluster

Use the displayed connection details from the Connect dialog to connect your mongo shell to the cluster. Specify the password for your user.

For example:

mongo "mongodb://mycluster0-shard-00-00-wpeiv.mongodb.net:27017,mycluster0-shard-00-01-wpeiv.mongodb.net:27017,mycluster0-shard-00-02-wpeiv.mongodb.net:27017/admin?replicaSet=Mycluster0-shard-0" --ssl --username kay --password 'atlasP@$$assw0Rd'

To connect with a different MongoDB user, update the user name and password.

To connect to a database other than admin but still authenticate to the admin database,

  • include the --authenticationDatabase admin command-line option and
  • update the database component of the connection string

For example, to connect to the test database and authenticate to admin:

mongo "mongodb://mycluster0-shard-00-00-wpeiv.mongodb.net:27017,mycluster0-shard-00-01-wpeiv.mongodb.net:27017,mycluster0-shard-00-02-wpeiv.mongodb.net:27017/test?replicaSet=Mycluster0-shard-0" --ssl --username kay --password 'atlasP@$$assw0Rd' --authenticationDatabase admin