Setting up MongoDB Atlas
A practical guide for beginners
In my past projects, I’ve been using Ruby on Rails for the backend. I wanted to try something different, and, of course, Node.js and MongoDB being so popular, I wanted to give it a try (and, most importantly, I’ll now understand what the heck is this MERN stack everybody is talking about!!! 😁)
So today I set up my first MongoDB Atlas project, how exciting!! I wanted to share this with you people who are starting
Step 1: Go to this link and create an account (it’s free!).
Step 2: Click on create a cluster. It will take a few minutes to be created.
Step 3: on the left menu, go to Security/Database Access. Here we need to create a new user (it needs to be different from the MongoDB login credentials you just gave). You should see this page:
Here I decided to give my user the rights to read and write to any database, but you can choose whatever suits you best.
Click on Add User. You should see a checklist popping up:
Step 4: following the checklist, now we need to whitelist our IP address: on the left bar menu, go to Security/Network Access. Click on Add IP Adress button and fill in the information:
Here I clicked on ‘Allow access from anywhere’ because it’s just a demo. But if you are building a real project then you want to click on ‘Add a current IP address’ and put your IP address.
Confirm.
Step 5: your cluster is all set and ready to connect.
To connect: click on Cluster on the left bar menu, you should get this:
Now click on CONNECT and then connect your application:
Here I didn’t change anything. The link you see will serve us later to plug in our Express App to access our database.
Note: if you want to access your data from this page, instead of clicking on CONNECT, you can go to COLLECTIONS.
Et voila! Pretty straightforward, right?
I hope you found this article useful!
Happy Coding 😀