MongoDB is a general-purpose, object-oriented, and dynamic NoSQL database server used in developing modern dynamic apps. In MongoDB, data objects are stored as separate documents in a collection unlike in traditional relational databases where rows and columns are used. It offers both the Community version which is free for download and the Enterprise version which is part of the Mongo Advanced subscription and has more features including; LDAP, Kerberos e.t.c
MongoDB Compass is the official GUI tool for MongoDB that aids in creating, reading, updating, and deleting databases graphically. This eliminates the need of running Mongo commands for every task. It allows one to explore data, run queries and interact with the database with full CRUD functionality. MongoDB is a much better alternative for the Mongo Shell since you can do all the operations done in the shell and more such as:
- Get real-time server statistics.
- Manage indexes.
- Its extendable via plugins
- Visualize and explore data stored in the database.
- Understand performance issues with visual explain plans
- Validate data with JSON schema validation rules.
With the above knowledge, we are set to begin this guide on how to install and use MongoDB Compass on CentOS 8/7 | Rocky Linux 8.
Step 1: Download MongoDB Compass
Unlike MongoDB Database, the MongoDB compass is not available in the base repository of CentOS 8/7 | Rocky Linux 8 therefore we have to download it from the official website. This is done by visiting the Compass official download page and select the platform on the right side as shown below.
For CentOS | Rocky Linux installation, we will select the RedHat package and download the .rpm file.
Alternatively, you can download the stable version of MongoDB compass on CentOS 8/7 | Rocky Linux 8 using Wget as below. First, you need to have Wget installed on your system.
sudo apt install wget
Then proceed and download MongoDB compass as below. By the time of documenting this guide, the latest stable version was 1.28.1 download it as below.
cd Downloads
wget https://downloads.mongodb.com/compass/mongodb-compass-1.9.0.x86_64.rpm
In case you want to download another version of MongoDB Compass, copy the download link on the official page and use Wget as above.
Step 2: Install MongoDB Compass on CentOS 8/7 | Rocky Linux 8
On CentOS 8/7 | Rocky Linux 8 launch the terminal and navigate to the directory where you downloaded the .rpm file. If you used a browser, your download will go to the Downloads directory. Navigate to the directory and you should see the file below
$ ls
mongodb-compass-*.x86_64.rpm
Now install MongoDB Compass with yum on CentOS 8/7 | Rocky Linux 8 Using the below command.
sudo yum localinstall mongodb-compass-*.x86_64.rpm
Dependency Tree:
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mongodb-compass x86_64 1.28.1-1.el7 @commandline 100 M
Installing dependencies:
libXScrnSaver x86_64 1.2.3-1.el8 appstream 30 k
mailx x86_64 12.5-29.el8 baseos 256 k
ncurses-compat-libs x86_64 6.1-7.20180224.el8.1 baseos 327 k
postfix x86_64 2:3.5.8-1.el8 baseos 1.5 M
redhat-lsb-core x86_64 4.1-47.el8 appstream 44 k
redhat-lsb-submod-security x86_64 4.1-47.el8 appstream 21 k
spax x86_64 1.5.3-13.el8 baseos 215 k
Transaction Summary
================================================================================
Install 8 Packages
Total size: 103 M
Total download size: 2.4 M
Installed size: 455 M
Is this ok [y/N]: y
Step 3: Run MongoDB Compass
To run MongoDB compass, navigate to the App Menu and launch it. It appears as below.
With MongoDB compass launched, plugins will be loaded as shown.
When plugins are loaded successfully, you will see this welcome window.
Step 4: Connect to a MongoDB Database
If you have a MongoDB instance installed on your system, you can connect to it by clicking connect as shown below.
Alternatively, create a database using this guide Install MongoDB 5 on CentOS 8/7 & RHEL 8/7
You will be connected to the existing database on your system.
Step 5: Connect to a Remote Database Instance
If you want to connect to a remote database instance, click on “Fill in connection fields individually“. In the Hostname segment, you can connect to the localhost database or the remote system by entering its hostname.
When done, click on connect. You should see your database as below.
Step 6: Create database using MongoDB Compass
While connected to a database, you can easily create and edit a database. In this database, let us create a database with the name mongotestdb and a collection with the name “user details“. Click on create database while on the above page
Click on “Create Database” and you should see your database appear as below.
Now we go into the database by clicking on it.
In our created collection, we will try and add data to it. First, click on it to open.
While on the above page, you can manually add the data or import data from your documents, normally a JSON or CSV file. Browse and load it, then select the type of file uploaded and click import.
To create a file manually, click on “Add data” and select “Insert Document” on the drop-down list shown.
You will enter details for your collection in the area paste one or more documents. Leave the Id as it is and click insert.
You should have your collection added.
Step 7: Drop a database in MongoDB Compass.
You can easily delete a database in MongoDB compass by navigating to the database on the left and click drop database as shown
Exit, disconnect from an instance in MongoDB compass by clicking on the connect button on the far left corner and select disconnect as shown.
Conclusion.
We have come to the end of this guide on how to install and use MongoDB Compass on CentOS 8/7 | Rocky Linux 8. We have seen how MongoDB compass aids one to easily create, edit and delete a database without using the shell commands. I hope this guide was helpful.
See more on our page: