October 21, 2021
How to install MongoDB Community Edition on CentOS 8

How To Install MongoDB Community Edition on CentOS 8

On this article we will learn how to install MongoDB Community Edition on CentOS 8. MongoDB is a free and open-source document database. Data is stored as JSON-like documents and classified as NoSQL database like Apache CouchDB.


MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). MongoDB offers both an Enterprise and Community version of its powerful distributed document database. The latest version of MongoDB when this article is written is version 4.4. MongoDB is available on Cloud and downloadable source. On this article, we will discuss how to deploy MongoDB Community Edition on CentOS 8.

MongoDB installation on CentOS 8

MongoDB only supports the 64-bit versions of these platforms. The installation process will be consist of several task, as described below :

  1. Prerequisite
  2. Configure the package management system (yum).
  3. Install the MongoDB packages.
  4. Enable and Startup the MongoDB Services
  5. Testing MongoDB


Before we are deploying MongoDB on CentOS 8 operating system, we have to fulfill the prerequisite first. As described on the MongoDB documentation, if MongoDB only supports the 64-bit versions of these platforms.

  1. CentOS 8 system with sufficient space
  2. Account user with sudo privilege or root account

Configure Package Management System

At this step, we will create repository file for MongoDB. The file name and location is /etc/yum.repos.d/mongodb-org-4.4.repo.

[ramans@otodiginet ~]$ sudo vi /etc/yum.repos.d/mongodb-org-4.4.repo

Then paste, the entries below :

name=MongoDB Repository
Add MongoDB 4.4 Repository to CentOS 8

Install the MongoDB packages

After MongoDB repository was added to the system, the next step is jus install it. To install the latest stable version of MongoDB, issue the following command: sudo dnf install -y mongodb-org.

[ramans@otodiginet ~]$ sudo dnf install -y mongodb-org
[sudo] password for ramans:
MongoDB Repository 4.0 kB/s | 2.5 kB 00:00
Dependencies resolved.
Package Architecture Version Repository Size
mongodb-org x86_64 4.4.1-1.el8 mongodb-org-4.4 10 k
Installing dependencies:
mongodb-database-tools x86_64 100.2.0-1 mongodb-org-4.4 55 M
mongodb-org-database-tools-extra x86_64 4.4.1-1.el8 mongodb-org-4.4 20 k
mongodb-org-mongos x86_64 4.4.1-1.el8 mongodb-org-4.4 22 M
mongodb-org-server x86_64 4.4.1-1.el8 mongodb-org-4.4 28 M
mongodb-org-shell x86_64 4.4.1-1.el8 mongodb-org-4.4 18 M
mongodb-org-tools x86_64 4.4.1-1.el8 mongodb-org-4.4 10 k
Install MongoDB 4.4

The output will be :

MongoDB 4.4 Community Edition installation was completed done

Enable and Startup the MongoDB Services

The next step after installation is starting and enabling MongoDB services. By issuing the following command:

[ramans@otodiginet ~]$ sudo systemctl start mongod
[sudo] password for ramans:
[ramans@otodiginet ~]$ sudo systemctl enable mongod

Then we verify, if the MongoDB service is already running properly by submitting command line : sudo systemctl status mongod.

[ramans@otodiginet ~]$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-10-21 10:23:57 PDT; 41s ago
Docs: https://docs.mongodb.org/manual
Main PID: 56528 (mongod)
Memory: 106.6M
CGroup: /system.slice/mongod.service
└─56528 /usr/bin/mongod -f /etc/mongod.conf
Oct 21 10:23:55 otodiginet systemd[1]: Starting MongoDB Database Server…
Oct 21 10:23:56 otodiginet mongod[56526]: about to fork child process, waiting until server is ready for >
Oct 21 10:23:56 otodiginet mongod[56526]: forked process: 56528
Oct 21 10:23:57 otodiginet mongod[56526]: child process started successfully, parent exiting
Oct 21 10:23:57 otodiginet systemd[1]: Started MongoDB Database Server.
MongoDB enable and start services
MongoDB Services

Testing MongoDB

In this step, we will use MongoDB, by login to and creating user on its database. To use MongoDB on ist console, just submitting command line : mongo, as described below :

1. Login to MongoDB console

[ramans@otodiginet ~]$ mongo
MongoDB shell version v4.4.1
connecting to: mongodb://
Implicit session: session { "id" : UUID("0f6b8954-1c73-48ec-bb8a-142f97110631") }
MongoDB server version: 4.4.1
Welcome to the MongoDB shell.
Starting MongoDB

2. Swith Login to ‘admin’

> use admin
switched to db admin

3. Create new database userdigimbadmin‘ with role as user Admin for any database and password passwordkoe

… {
… user: "digimbadmin",
… pwd: "passwordkoe",
… roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
… }
… )
Successfully added user: {
"user" : "digimbadmin",
"roles" : [
"role" : "userAdminAnyDatabase",
"db" : "admin"
MongoDB Create user

4. Show the user that was created.

> show users
"_id" : "admin.digimbadmin",
"userId" : UUID("d7db8732-8169-472c-a7ef-0b7f50f66d2b"),
"user" : "digimbadmin",
"db" : "admin",
"roles" : [
"role" : "userAdminAnyDatabase",
"db" : "admin"
"mechanisms" : [
MongoDB Show users


We have learnt how to install MongoDB Community Edition version 4.4 (so far the latest version) on CentOS 8. This article is very simple, only a little step for knowing one of the famous NoSQL database, MongoDB.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *