DEV Community

Cover image for How to use MongoDB Atlas?
Suchitra
Suchitra

Posted on • Edited on

How to use MongoDB Atlas?

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

You can skip 👇 this process as well, it's totally up to you!

Screenshot (263)

Then you will be seeing this 👇 choose to create cluster Free.
Screenshot (264)_LI

Leave everything as default and click on create cluster!
Screenshot (265)

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)

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)

Boom🎇, you created your very 1st cluster 😀

Screenshot (268)

Now click on connect button!
Screenshot (273)_LI

Click on connect with mongo shell.

Screenshot (291)_LI

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

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

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

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
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)

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)

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

Now copy the URL

Screenshot (292)_LI

Now you can use this URL in your project, just replace this URL with local MongoDB URL.

Screenshot (294)_LI

See in this blog post website(my project) I have added a Post
What is Linux?
Screenshot (297)

And now it is stored on my MongoDB Atlas
Screenshot (298)
Screenshot (300)

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

Top comments (0)