Using the mongo shell and compass

๐Ÿ“Œ Installing the mongo Shell on a Linux machine

Use this article: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/โ€‹

๐Ÿ“Œ Connecting to Our Class Atlas Cluster from the mongo Shell

Use this command:

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

๐Ÿ’กExplanation

Because you are connecting to a cluster, you need to give the Mongo Shell the name of all the servers in the cluster.

  • To connect to another database change the word test in the command

  • To make a secure connection use: ssl

  • Then use the username and password

๐Ÿ’กSome mongo shell commands

  • To list databases on your current sandbox cluster: show dbs

  • To show the collections in that database: show collections

  • If you want to change the database use: use DBNAME

๐Ÿ“Œ Creating an Atlas Sandbox Cluster:

โ€‹https://cloud.mongodb.com/user#/atlas/register/accountProfileโ€‹

Detailed instructions found here: https://university.mongodb.com/mercury/M001/2019_December_10/chapter/Chapter_2_The_MongoDB_Query_Language_Atlas/lesson/5ccc5805fcdfc9cfbb5065c5/problemโ€‹

๐Ÿ“Œ Connecting to Your Sandbox Cluster from the mongo Shell

Use the same command that was used for the first time you connected something from the database to the shell, with your username and password.

๐Ÿ“Œ Connecting to Your Sandbox Cluster from Compass

The only important thing here is to find the primary cluster. Then fulfill the form, and use the same username and password as before.

Last updated

Was this helpful?