Get started with Compass and Atlas
Installing Compass
Download MongoDB Compass from this.
What is MongoDB Compass?
MongoDB Compass is a powerful GUI (graphical user interface) for querying, aggregating, and analyzing your MongoDB data in a visual environment.
What we can do with Compass?
- Connect to your deployment
Connect to a MongoDB deployment hosted on MongoDB Atlas, or a deployment hosted locally on your own machine.
When you open Compass, an initial connection dialog appears:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
You can connect your deployments by either:
- Use connection string
- For local database:
mongodb://localhost:27017
- For Atlas, to obtain the connection string URI (we talked about this in the Atlas session):
- Navigate to your Atlas Clusters view.
- Click Connect for your desired cluster.
- Click Connect with MongoDB Compass.
- Copy the provided connection string.
- Connect
Click the Connect button to navigate to the Compass Home Page.
- Import and Export your data
Import data from CSV or JSON files into your MongoDB database.
You can use MongoDB Compass to import and export data to and from collections
Compass supports import and export for both JSON and CSV files
Export Data from a Collection:
If you specify a filter, Compass only exports documents which match the specified query.
- Step 1: Connect to the deployment containing the collection you wish to export data from.
- Step 2: Navigate to your desired collection
- Step 3: Click Collection in the top-level menu and select Export Collection
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
Compass displays the following dialog:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
To ignore the query filter and export your entire collection, select Export Full Collection and click Select Fields.
- Step 4: Select document fields to include in your exported file.
Only fields that are checked are included in the exported file.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
- Step 5: Choose a file type and export location.
Under Select Export File Type, select either JSON or CSV. If you select JSON, your data is exported to the target file as a comma-separated array.
Then, under Output, choose where to export the file to.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
Import Data from a Collection:
MongoDB Compass can import data into a collection from either a JSON or CSV file.
Before you can import your data into MongoDB Compass you must first ensure that it is formatted correctly.
-
Step 1: Connect to the deployment containing the collection you wish to import data into.
-
Step 2: Navigate to your desired collection.
-
Step 3: Click the Add Data dropdown and select Import File.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Step 4: Select the location of the source data file under Select File.
-
Step 5: Choose the appropriate file type.
Under Select Input File Type, select either JSON or CSV.
If you are importing a CSV file, you may specify fields to import and the types of those fields under Specify Fields and Types. The default data type for all fields is string.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
To exclude a field from a CSV file you are importing, uncheck the checkbox next to that field name. To select a type for a field, use the dropdown menu below that field name.
For both JSON and CSV file imports, you can toggle Ignore empty strings and Stop on errors:
- If checked, Ignore empty strings drops fields with empty string values from your imported documents. The document is still imported with all other fields.
- If checked, Stop on errors prevents any data from being imported in the event of an error. If unchecked, data is inserted until an error is encountered and successful inserts are not rolled back. The import operation will not continue after encountering an error in either case.
-
Step 6: Click Import
MongoDB Atlas
What is MongoDB Atlas?
MongoDB Atlas is a cloud database that handles all the complexity of deploying, managing, and healing your deployments on the cloud service provider of your choice. That is to say, you are now can share with the world your database by using Atlas.
Previously, we have talked about how to connect and use the local database in your machine. Your application needs to connect to the database. Then, making CRUD manipulates the data. So if you shut down or break your computer, there would be no data to query.
Mongo Atlas is a cloud service, in plain languages, it is a computer network (a lot of computers) that runs 24/7. So by hosting our database on Atlas, any backend API that connects to this database could get live and update data.
One more example, imagine that you and your friends are working on the same project and that you need to update the data frequently. How to sync your database on the go? There might be a way from what we have learned so far. Any time you finish your job on the database, export and send them to your friends. They will import the database and keep working on it. That sound not efficient. So here is when Atlas comes in.
Get started with MongoDB Atlas
-
Creating a MongoDB Atlas account
- Register an Atlas account from this place. You can sign-in with Google account if you have one.
-
Create an Organization and project
- Organization: allow you to group and define users and teams, and grant them access to the different projects.
- Project: allow you to define and organize resources such as database clusters. A common way to use projects is to define each environment as a project.
-
Hit Create New Organization
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Name your Organization. Make sure that your cloud service is MongoDB Atlas, then hit Next.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Hit Create Organization
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Hit New Project
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Name your project
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Hit Create Project
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Setting up a Cluster in MongoDB Atlas
-
This is where you start. Hit Build a Database
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Choose Shared package, click Create
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Select the region that is geographically closest to your location. On the bottom of the page, you can change the cluster name. Then hit Create
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
The new Cluster is proccessing. Create a user that can access to this database
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Add the IP address that can access to the database. For now, just hit Add My Current IP Address. We'll grant the access others later in this instruction. Then, hit Finish and Close
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Now, waiting till your cluster is ready as show in this picture below
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Grant access to your database
Choose tab Network Access on the side bar
-
Click ADD IP ADDRESS
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
-
Click ALLOW ACCESS FROM ANYWHERE. Then Confirm
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More โ
You can choose tab Database Access on the sidebar to see the user that we just created for a moment.
Both Database and Network access define from whom and where can access to your database with the right URI. Let's get to the next step to see how we can access to our database
-
Accessing a MongoDB Atlas Cluster
-
Choose Connect

-
You'll see this pop up

-
Choose tab three to connect the cloud Atlas database from your Compass. Then choose I have MongoDB Compass. Then copy the connection string and pass to your Compass. (Remember to change <password>
to the one that you create before)

-
Choose tab two to connect the cloud Atlas database from your back-end application.

-
Sample data
Load Sample data for practicing
-
Choose Load Sample Dataset

-
Choose Load Sample Dataset

-
When the dataset is loaded the graph labeled "Logical Size" on the right side of the screen should go up and display the size of the dataset that is above zero and below 512 MB. Your graph may look different than the picture below.
