Connect MongoDB Atlas & MongoDB Compass

How to Connect MongoDB Compass with Atlas

Are you interested in Non-relational databases and have just started learning about MongoDB? If yes, then installing MongoDB compass can give a huge boost in mastering one of the top-5 databases in the world. 

This MongoDB GUI Viewer enables you to manage MongoDB database right from your own computer (Windows 10 in our case).

In this article, we’ll learn MongoDB Compass download,  installation and then connecting it with MongoDB Atlas.

An important point to note here is that the Compass cannot only be configured and linked with the MongoDB database on Atlas but you can do that on any other platform which runs the MongoDB database.

However, in this article, we’ll just discuss the MongoDB Compass.

I hope this will give you a good idea about the GUI platform and you can use this knowledge to set up your MongoDB ecosystem on any other platform as well.

Also Read: Understanding GET and POST Methods in Express.JS

What is MongoDB Atlas?

MongoDB Atlas is an online, cloud-based Database-As-A-Service (DaaS) platform provided by MongoDB that allows you to create and manage MongoDB databases (a.k.a Cluster).

It has both free and paid versions.

What is MongoDB Compass?

MongoDB Compass is a GUI Tool or viewer that helps you manage, track and visualize your MongoDB cluster without having to know the MongoDB Query Language.

This helps you manage the database more effectively as you’re able to run ad-hoc queries on your database and observe the output.

 

Is MongoDB Compass Free?

The Compass Community version is absolutely free but of course, offers limited options such as it does not offer Schema Analysis, Real-Time Server Analysis or Document Validation, etc.

The premium version, such as the Enterprise and the Enterprise Read-Only versions of Compass provide much exciting features but they may cost you up to $6,500 to $10,000 per server per year.

I’m quite sure that if you’re just starting out, the free version has you covered quite sufficiently.

Is MongoDB Compass absolutely necessary?

No, it isn’t. Since Compass is just a GUI Tool that speeds up the development process,  so, if you want to make your NodeJS or development in any other programming language which uses MongoDB as a database, simpler, by using Compass you will make your life easier. 

Let’s go step-by-step through the process of connecting your MongoDB with Atlas.

Also Read: How to install Node.JS on Windows 8 (32-Bits, 64-Bits)

How to create a cluster on MongoDB Atlas?

Before creating a cluster on Atlas, you need to sign up on MongoDB’s website. Once done, follow the below steps:

  1. On the main page, click Build a new cluster

    MongoDB Atlas Build a Cluster

  2. Select the free option under the Shared Cluster section. This should be free to create
    MongoDB Atlas Build a Cluster
  3. You can see different clusters, select any of the Free clusters available. 
    Atlas Free Clusters
  4. Scroll down to edit the basic settings of your cluster such as name and backup settings etc. and then click the Create Cluster button.
    Atlas - Edit Cluster Name
  5. MongoDB takes around 2-5 minutes to build your cluster.

Once you have the Atlas cluster created, it’s time to go back to your computer and install the Compass.

MongoDB Compass – Download & Configure on Windows 10

  1. To start using Compass, you need to first download it from the MongoDB’s website. Here’s a link to the download page.
  2. Select the version that you want to download. Since there are more than one versions of Compass, read the options below to see features available in different Free versions.
    Download MongoDB Compass
  3. In the platforms, list-of-values select either the zip or the installer file. Personally, I’d recommend you to download the installer file (MSI) and then click the download button. For e.g. I selected the option that says Windows 64-Bit (7+) (MSI) to install Compass
  4. Go to the location of the downloaded installer file, double-click and complete the installation process. By default, Compass installs in your Program Files folder.

Create a new user in Atlas

After creating the cluster you need to create a new user in Atlas. Follow the below steps to create a new user:

  1. Click on Database Access and then Add New Database User
    MongoDB Atlas Create a Database User
  2. Select Password as the Authentication Method
    Atlas Enter Database Username and Password
  3. Enter Username and Password in the respective fields
  4. Select Read and Write to any Database and then click Add User

Whitelist your IP

This step is necessary to connect the Atlas cluster with different platforms as it allows different IPs to connect with Atlas. We will whitelist all the IPs trying to connect with Atlas. 

  1. Click on Network Access and then click Add IP Address
    MongoDB Atlas Whitelist IP Address
  2. Click Allow Access from Anywhere to whitelist all the IPs and then click Confirm
    Add IP Whitelist Entry

 

How to connect MongoDB Atlas with Compass?

  1. On the main dashboard of Atlas, inside the Clusters window, click the Connect button.
    Connect Atlas Cluster
  2. From the three available options, click, Connect using MongoDB Compass.
    Connect Atlas Cluster with Compass
  3. Select I have MongoDB Compass option, copy the Connection String and then click the close button.
    MongoDB Connection String
  4. Open MongoDB Compass on your computer and then click New Connection
  5. Enter your connection string which you copied from Atlas. Remember to replace <password> with your actual password and then click Connect.
    MongoDB Compass Enter Connection String

    Note: You can enter information individually by clicking the Fill in connection fields individually link, however, in this tutorial, we will take the easy route.

Final Word

Time to summarize what we’ve learned in this article. So the crux of our discussion is:

  1. If you want a free platform to learn MongoDB, the Atlas cloud platform is a way to go.
  2. Since Atlas is cloud-based, you can use MongoDB Compass to access your Atlas cluster. 
  3. Compass allows you to add/edit/delete and track your MongoDB database on Atlas.
  4. After signing up on Atlas, create a free cluster, add a new user and then whitelist your IP so that the compass can connect with your cluster.
  5. You can download and install Compass on your Windows 10 machine.
  6. Copy and paste the Connection String from Atlas in Compass to connect both. 

Similar Posts