How to use MongoDB Atlas?
Tags: mongodb, database, cluster, beginners
Published: 2021-06-28 16:42:51

In this article, I am assuming that you have a bit knowledge of MongoDB locally.

Here I will be guiding you **How can you use MongoDB Atlas in your website?** 
 
So, the prerequisite is some knowledge of MongoDB database, but don't worry if you don't have you can follow this MongoDB docs 👇

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

In this article, my main focus will be in MongoDB Atlas. So, let get started …

The very 1st step you have to do is go to MongoDB Atlas https://www.mongodb.com/cloud/atlas and sign-up.

After that, login with your credentials.
You will be seeing this page:
![Screenshot (262)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wclrsvkfxkawteizh9u4.jpg)
 
You can skip 👇 this process as well, it's totally up to you!

![Screenshot (263)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5bmtmnp8aj65qljt69ky.png)
 
Then you will be seeing this 👇 choose to create cluster Free.
![Screenshot (264)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/feimm3my3d6adyspbe9i.jpg)
 
Leave everything as default and click on create cluster!
![Screenshot (265)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3idsyqresd6j3hpm494.png)
 
Enter your credential(**username** and **password**) for database connection and remember it or save it somewhere because it will require when you will connect through your website as db connection!
![Screenshot (266)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4n2wpvdwctuyu0mmo3zk.png)
 
Here, you have to put IP address list so that it can be accessible with only which you will be selected. I have putted 0.0.0.0 (everyone accesses) you can put your personal IP as well.
![Screenshot (267)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cxxz69ffqk6nhelt9kx.png)

Boom🎇, you created your very 1st cluster 😀

![Screenshot (268)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2iuw59xtvdrxlm2ahf0.png)
 
Now click on connect button! 
![Screenshot (273)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sd9vgdr4cv1csrumkker.jpg)

Click on connect with mongo shell.

![Screenshot (291)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6aafw8okxikzorftgbd.jpg)
 
 
If you haven't downloaded the mongo shell before, go through the specified link and download it 1st, its easy and straight forward process.

 
 
Now, copy the connection URL.
![Screenshot (276)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o6pk8p8e4nha6yxl0tfc.jpg)
 
And open your CMD/ hyper/ git bash anything which you generally use and paste the URL(not required to any specified directory, it will work fine in any directory).


 ![Screenshot (280)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sc5u1a4512x9z7q6nrd.jpg)

It will ask for password so after entering the password which you initially set, that time I told you that keep safe that password right? 
It required here for the mongo DB atlas connection! 

If all steps you follow correctly, then you will see this kind of thing in your CMD:
So, Congratulation, you made your connection with MongoDB atlas.

![Screenshot (282)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39oupeqd3tc5vbj248tt.jpg)
 
So, the next step is … go to collection in cluster and create your own database and test whether it is working or not!
![Screenshot (285)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g88fx5dtuqsal2bznxlo.jpg)
Here, I am showing you with sample datasets, but you can also create your database, after getting some idea with sample dataset definitely you can create your own database and test it with your mongo shell!
![Screenshot (286)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzif5h9dyk1yb8z63nmc.png)

Now, you will be seeing that in your cluster number of sample databases are created, right?

Just go to mongo shell and type:
`show dbs`
Now you will be seeing all the sample databases which are present in your MongoDB cluster:)

![Screenshot (288)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbahlop9l3ta0i1990jw.png)

Now, you can also create your database and collection and do test with that as well.
 
Till now what we did
We created our cluster, connect with mongo shell, created DBs, and tested!

Now, the question arises is that how can we use the database in our website?? 
So, don't worry!! It's simple(if you have knowledge in MongoDB)

Just go to MongoDB atlas and in cluster go to connect section and
click it.

![Screenshot (290)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzqktfg80ohl1lbo9bjy.jpg)
 
Now copy the URL

![Screenshot (292)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nuh6njw8cej7m8nspp44.jpg)
 
Now you can use this URL in your project, just replace this URL with local MongoDB URL.

![Screenshot (294)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44eyj8txzbke7f8cyk4u.jpg)

See in this blog post website(my project) I have added a Post
What is Linux?
![Screenshot (297)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlh051qapxipwbo8sh3s.png)

And now it is stored on my MongoDB Atlas
![Screenshot (298)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ub0rsiib2vg98d2li9og.png)
![Screenshot (300)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4ur8rymye3v3a63q1q7.png)

All done, you set your project with MongoDB Atlas.
Test it and congratulations!

### Thanks for your patience and do comment if you have any type of suggestions will be appreciated ❤
[![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cawwn08bx5rh2s9bax2x.png)](https://www.buymeacoffee.com/suchitra)

{% user suchitra_13  %}