How to connect mongoDB Atlas with mongosh Shell In easy steps

In an Easy meaningful way, we are going to Connect MongoDB Atlas with localhost mongosh Shell

Especially for For Window system users

Step1

Be free till create cluster on MongoDB Atlas.
Now Click on > Connect > Choose one of “I do not have the MongoDB Shell installed” or “I have the MongoDB Shell installed”

Step2
Download “mongosh” on your dedicated system to choose system profile and version > click on “Download mongosh(Your_Version)”

Step3

Add <your mongosh’s download directory>/bin to your $PATH variable

For this make a outer folder on C:\ Drive with “MongoDB” name (not in "C:\Program Files")
Extract your mongosh setup

Step4

Search or Go to “Edit the system environment variables” > Environment Variables > Double click on “Path” > Create New > Paste “C:\mongoDB\mongosh-1.0.0-win32-x64\bin” > ok > Apply > ok

“Till now you setup your mongosh bin path in Environment Path variables” OK

Step5

Open commad prompt > Paste “mongo “mongodb+srv://cluster0.1olaw.mongodb.net/myFirstDatabase” --username Rakesh-PC” >
Enter Your database Password

NOTE

  • Replace myFirstDatabase with the name of the database that connections will use by default. You will be prompted for the password for the Database User, Rakesh-PC

  • If you don’t created database yet, Dont worry ! Connect with bydefault database “myFirstDatabase” You may create a new database later and replace this database to other, its your choice

Step6

Now You see message like this, which means you are connected from MongoDB Atlas db to mongosh Shell

connecting to: mongodb://cluster0-shard-00-00.1olaw.mongodb.net:27017, cluster0-shard-00-01.1olaw.mongodb .net:27017,cluster0-shard-00-0 2.1olaw.mongodb.ne t:270 17/myFirstDatabase5 authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-8ipxy8-shard-0&ssl=true

Implicit session: session { “id” : UUID(“c37l503a-3074-486h-ae5e-c7a283936d41”) }
MongoDB server version: 4.4.6
MongoDB Enterprise atlas-8ipxy8-shard-0:PRIMARY> show dbs

------------------------------------------For More ----------------------------------------------------------------
Question1
What is Organization in MongoDB Atlas
An organization can contain multiple projects (previously referred to as groups). Under this hierarchy structure:

  • Billing happens at the organization level while preserving visibility into usage in each project.
  • You can view all projects within an organization.
  • You can use teams to bulk assign organization users to projects within the organization.
    When you create an organization, you are added as an Organization Owner for the organization.

Question2
What is This Cluster0 left side of connect
Cluster0 is visible under Database option and left side of connect. And under this you can see three or more clusters series as primary, and secondary cluster

so In the context of MongoDB, cluster is the word usually used for either a replica set or a sharded cluster . A replica set is the replication of a group of MongoDB servers that hold copies of the same data over multiple clusters set as primary and secondary clusters on the priority based. This is a security and back plan provided by dbms services to prevent from and loses like, destroy database data from fire, broken, expiary etc. This is a fundamental property for production deployments as it ensures high availability and redundancy, which are crucial features to have in place in case of failovers and planned maintenance periods.

I hope this article forum helps you… Please write your review. Because I believe in learn with helping community and grow

1 Like

Welcome for the initiative to help community

Couple of points
1.In the writeup you downloaded mongosh but in the command you are using mongo
Add few words on mong vs mongosh
2.You have added double quotes at begin of mongo.Check this
3.You have put your clusterid/cluster name in the connect string.Mask it and explain how you got it from connect page and mention that it needs to be replaced with users own cluster id/cluster name

2 Likes

Thanks for your valuable support. I will.

A post was split to a new topic: I am trying to get stats (db.stats()) it returns all “0”