Connect to your MongoDB Atlas Cluster! [5]

Connect to your MongoDB Atlas Cluster! [5]

Now that you've set up an Atlas cluster, you can connect to it from the MongoDB shell. Follow the steps below to install MongoDB, MongoDB tools and MongoDB Shell in your system.

1. Click here to download MongoDB

Select your OS platform, download and then install MongoDB in your system.

2. Click here to download MongoDB Tools

Select your OS platform, download and then install MongoDB tools in your system.

3. Click here to download MongoDB Shell

Select your OS platform, download and then install MongoDB shell in your system.

After installation of above 3 software's.

Do add MongoDB path in your system environment variables PATH. I'm using Windows OS, also versions may be different for you.

Similarly add MongoDB tools path in your system variable PATH, if you are using Windows OS.

Do not forget to confirm your MongoDB installed properly without any issues by running command:

mongo --version

Final step to connect to your Atlas Cluster!

If you remember in last article we have created a cluster. (if you are new in creating cluster, or you do not have MongoDB Cluster - Click here to create new MongoDB Cluster)

Now, to connect to your MongoDB cluster:

1. Click over "Connect" in the Atlas Cluster.
2. Choose to "Connect with the mongo shell".

3. Select "I have the mongo shell installed", then Copy the connection string.

From the second point of image above, copy connection string.

mongosh "mongodb+srv://cluster0.*****.mongodb.net/myFirstDatabase" --username m-student

Run your connection string in your command line:
This will prompt you to enter password, you need to enter your Database User password we created in previous article.

Congratulations you have successfully connected to your MongoDB database cluster from your local machine using MongoDB Shell.

Next: Importing, Exporting, and Querying Data
How does MongoDB store data?

👉ALL MONGODB SERIES


Reference: university.mongodb.com | MongoDB, Inc.