22
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 π
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.
You can skip π this process as well, it's totally up to you!
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!
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.
Boomπ, you created your very 1st cluster π
Click on connect with mongo shell.
If you haven't downloaded the mongo shell before, go through the specified link and download it 1st, its easy and straight forward process.
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).
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.
So, the next step is β¦ go to collection in cluster and create your own database and test whether it is working or not!
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!
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:)
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.
Now copy the URL
Now you can use this URL in your project, just replace this URL with local MongoDB URL.
All done, you set your project with MongoDB Atlas.
Test it and congratulations!
22