DropVPS Team
Writer: Cooper Reagan
How to install mongodb on centos 8

Table of Contents
What you will read?
MongoDB is a popular NoSQL database suited for handling large volumes of data. Installing MongoDB on CentOS 8 requires configuring repositories and system settings properly. Follow the steps below to get MongoDB up and running smoothly.
Step 1: Disable CentOS 8 AppStream Module
MongoDB packages conflict with CentOS 8’s default AppStream modules. Disabling the default MongoDB module prevents package conflicts.
sudo dnf module disable mongodb -y
Output example:
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Disabling modules:
mongodb CentOS-8 - AppStream 0
Transaction Summary
================================================================================
Disable 1 Module
Is this ok [y/N]: y
Complete!
Step 2: Create MongoDB Repository File
Add the official MongoDB repository to your system to install the latest MongoDB version. This step creates a repo file with MongoDB download details.
sudo tee /etc/yum.repos.d/mongodb-org.repo > /dev/null <<EOF
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF
Step 3: Install MongoDB Packages
Install MongoDB server, shell, and tools packages from the configured repository. This ensures you get all necessary components for running and managing MongoDB.
sudo dnf install -y mongodb-org
Output example:
Installed:
mongodb-org-server-5.0.x86_64 mongodb-org-shell-5.0.x86_64
mongodb-org-mongos-5.0.x86_64 mongodb-org-tools-5.0.x86_64
Complete!
Step 4: Enable and Start MongoDB Service
Enable MongoDB to start on system boot and launch the service immediately. Use systemctl commands to manage the service status.
sudo systemctl enable mongod
sudo systemctl start mongod
Check the service status:
sudo systemctl status mongod
Expected output snippet:
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled)
Active: active (running) since Wed 2025-05-15 10:00:00 UTC
Step 5: Verify MongoDB Installation
Confirm MongoDB is working by connecting with the mongo shell and checking the server status.
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
Sample output:
{
"authInfo" : {
"authenticatedUsers" : [ ],
"authenticatedUserRoles" : [ ]
},
"ok" : 1
}
MongoDB is now installed and ready to use on CentOS 8. For configuration customization, refer to the /etc/mongod.conf file. Remember to secure MongoDB for production use by enabling authentication and firewall rules.