MongoDB Compass makes it easy for you to use MongoDB with a graphical user interface. Here we show you how to install and use this tool.
MongoDB Compass: manage your databases more easily
MongoDB is one of the most popular and successful NoSQL solutions. This database management system focuses on storing and managing large data sets that can be processed in different formats and grouped into collections in the form of BSON documents. Although the solution strives to be as intuitive as possible, working with command lines requires a little prior knowledge and high precision.
With MongoDB Compass, you have a clear graphical user interface which allows you to view, edit and analyze your data. Here we explain how to install MongoDB Compass on your system and what possibilities this tool offers you on a daily basis.
MongoDB Compass Features
MongoDB Compass can do everything the shell makes possible. Thanks to its interface user-friendlymany tasks will be much simpler and faster to perform. Access extends to individual documents, collections, and building an entire database. Some of the tasks you can perform with MongoDB Compass include:
- the creation of new databases, collections and documents
- the representation of the data you have deposited in your database
- adding, editing and deleting a document
- a thorough and complete analysis of your system and the databases created
- permanent monitoring of your system's performance
- data monitoring and adaptation according to the principles of the JSON format.
Note: MongoDB Compass is free.
Installation Prerequisites
Before you can install MongoDB Compass, you must first choose a version of the tool:
- MongoDB Compass is the full version.
- MongoDB Compass Read-Only does not offer any possibility of modification or deletion of documents.
- MongoDB Compass Isolated works independently of the network.
All three versions are available for download on the MongoDB website.
MongoDB Compass is compatible with most popular operating systems. You can get the graphical user interface (GUI) for OS X, Ubuntu, and Windows, among others.
To use the tool, you must already have the MongoDB document-oriented database installed. To learn how to do this, check out our comprehensive MongoDB tutorial . You must also have administrative rights. While the installation steps may vary slightly depending on the system, the actual work with MongoDB Compass is the same on all machines.
If you are using OS X or Windows, simply navigate to the website linked above, select the appropriate version, download it, and follow the installation wizard. If you want to install MongoDB Compass on Ubuntu, for example, you will need sudo rights. If you have them, you can do the following:
- Go to the MongoDB Compass website and copy the download link for the appropriate version.
- Use the command
wget
. For version 1.39.4 it looks like this:
wget https://downloads.mongodb.com/compass/mongodb-compass_1.39.4_amd64.deb
bash
- Use the command
apt
to install MongoDB Compass. Here's how to use it:
sudo apt install ./mongodb-compass_1.39.4_amd64.deb
bash
- Once the installation is successfully completed, open MongoDB Compass:
First you will see a start screen. In the following paragraphs we will explain how to proceed from there and what options are available to you.
Establish a connection with the server
To use MongoDB Compass, you first need to establish a connection to your server. The easiest way to do this is as follows:
- First click on “New Connection” at the top left to establish a connection.
- At the top of the screen, you will find the option “Fill in connection fields individually”. Click on it.
- Now enter the IP of your remote server in the “Hostname” field.
- If you have not manually changed the port before, you can work with the default value “27017”.
- If you want to use additional security measures, select “Username / Password” under “Authentication” and save the login data you usually use for MongoDB.
- Once you have completed the previous steps, MongoDB Compass will connect to your server. You will then get an overview of your databases on the right.
Create a database with MongoDB Compass
If you have not yet created a database or if you want to create an additional one, nothing could be simpler. To do this, follow these steps:
- First click on the “CREATE DATABASE” button at the top. This opens a pop-up window.
- Give your new database a name.
- Also give your collection a title.
- Click on “CREATE DATABASE” at the bottom right.
Add or create documents
You can also save your data with MongoDB Compass in BSON documents. You also have the option to create and insert new documents in the user interface. To do this, simply follow these steps:
- Click on the appropriate database on the left side.
- Then select the correct collection. A new window will open.
- Under “Add Data” you have the option to either import an existing document (“Import File”) or create a new document (“Insert Document”).
- If you want to add an existing document, click on “Import File”, select the file and indicate what format it is. Then click on “IMPORT”.
- To create a new document, click on “Insert Document”. A new window will also open, where you can add values in JSON format or key/value pairs. Once the document is edited, click on “INSERT”.
MongoDB Compass: View, Edit, or Delete Documents
In MongoDB Compass, you can also view, edit, or delete documents. Here we briefly explain these different operations.
View documents
If you want to view the contents of a particular document, MongoDB Compass offers you three different views:
- in list form
- in JSON preview
- in table form
Just select the appropriate mode from the top bar. You will find it next to the “VIEW” option.
Note
To can edit and delete documentsyou need MongoDB Compass in its full version or in its isolated version. This is not possible in the Read-Only version.
Edit documents
If you want to edit a document, follow these steps:
- Display the corresponding document.
- Click on the pencil symbol at the top right.
- Select the field you want to edit.
- When you are done, confirm by clicking “UPDATE”.
Delete documents
It is very easy to delete a document in MongoDB Compass:
- Display the relevant document.
- Make sure you no longer need the document.
- Click on the trash icon at the top right and confirm the operation.
Advice
MongoDB Compass provides a simple search function (Query Bar) for queries in specific collections. We show you how to create more complex queries in the article “Creating MongoDB Queries”.