How to setup MongoDB Atlas database for your project

ochoko ebuka
5 min readMay 18, 2019

Hey, Node devs!! if you have been confused about how to set up a MongoDB Atlas database for your development, here is a good solution to what you have been looking for.

Sit back, follow these steps and boom you will be running your development using a live MongoDB database in minutes.

Table of content

1.Getting started

2.Clusters

3.Creating a new project

4.Adding members/permission settings

5.Building your project cluster

Getting Started

Firstly in other to get started with connecting your MongoDB Atlas online, you must have prior knowledge of node.js, express.js, mongoose and must have set up your node development environment, Also you must have registered, or have an account with https://cloud.mongodb.com .

Cluster

Clusters in cloud computing refer to a group of cloud storage system working together on one system to provide users with independent data storage accessibility to house their projects.

clusters are being provided by cloud providers, MongoDB Atlas supports the cloud providers which provides cloud services for cluster creation and these providers are

  1. AWS(Amazon web services )
  2. Google cloud platform
  3. Azure

Creating new project

In other to create a new project in MongoDB Atlas, you need to click on the project button on the top left side of the Clusters page which shows you a drop-down where you will click on the new project link.

On clicking on the new project, you will be navigated to a page where you will have to give a name to your project.

Adding members/setting permissions

After successful completion of the above task and by clicking on the next button, you would be navigated to the add member and permission setting page, where members could be added and certain data access right given to them depending on the task they carry out in the project. With this, access right can be managed efficiently.

After adding members to the project , click on the create project button which leads you to the project cluster that houses the particular project you created . Here you can click on the security hyperlink which will displays a page where you would can add new user by clicking on the add new user button, which displays a form where you would are required to type your desired username and a password options (you can use the auto generate button for a guarantee of a strong password) which would serve as the cluster details for the connection to the database of that particular project. if you used the Auto generate button you can click the show link in the form field to make the password visible for copy.

Building your project Cluster

On successful adding of user in the security sub-page of your new project , click on the overview link to display to navigate you to where you can your build cluster. Here you will have to choose a cloud provider from the three options given , for a project on development you might want to use the free teir from you desired cloud provider for different regions.

On selecting of a cloud provider and tier region, click the create button at the bottom right to create your cluster for the project.

More on Security

For a little more security, atlas enforces that all connection made to the cluster must be from a trusted IP address, in order to achieve this, when we return to our project, click on the security on, then click on the IP Whitelist tab to add IP address you would be using to access this cluster, if you don’t know your IP address you can type into any of your desired search engine “My IP” to get your IP address, copy and paste it but for development you might want to use the “ALLOW ACCESS FROM ANYWHERE” option to allow all IP address (Note: if you are over a proxy like many companies do you might want to ask the admin for your IP address”), click the confirm button to complete

Connecting to your database

In other to connect your application to your cluster you need to click on the connect button which pops up a modal form-like page. Next , Click choose a connection method button on the bottom right corner of the modal, this will navigate you to the connection method modal where you will click on the connect to my application link to reveal your connection string

Click on the copy button, to copy the connection string which has the username you filled in the cluster security form you filled earlier cluster security sub-page this is what you would use to connect to your application. For my sample project, am working with node and mongoose, the below image shows how a typical mogoose connection would look like when connecting to my cluster.

Connecting project database to mongoDB compass

MongoDB compass is a mongoDB software which you as a developer uses to access the project database/document directly , without using accessing it via the web . In other to set up mongoDB compass click on https://docs.mongodb.com/compass/master/install/ , And follow the steps on the mongoDB documentation in other to download and install MongoDB compass.

After successful installation process, launch the software , with the copied click on the “connect or Ctrl + N” option if you copied your connection string rightly, Compass should detect that there is a connection string in your clipboard and will ask to use it automatically, click ok to auto fill the required fields, all you have to do is fill your password (you can use the create favorite to save your connection details). Click the connect to access your database from Compass.

--

--