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:
You can skip 👇 this process as well, it's totally up to you!
Then you will be seeing this 👇 choose to create cluster Free.
Leave everything as default and click on create cluster!
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.
See in this blog post website(my project) I have added a Post
What is Linux?
And now it is stored on my MongoDB Atlas
All done, you set your project with MongoDB Atlas.
Test it and congratulations!
Top comments (0)