How to Install MongoDB 8 on Rocky Linux 10

MongoDB is a popular NoSQL database that stores data as JSON-like documents. It allows fast, scalable, and flexible data management, supports replication and sharding, and uses the MongoDB Query Language (MQL) for access.

Add MongoDB Repository

MongoDB is not available in the default Rocky Linux 10 repositories, so you must add it manually.

Create the repository file

vi /etc/yum.repos.d/mongodb.repo

Add the following lines

[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/10/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc

Install MongoDB

dnf clean all
dnf makecache
dnf install -y mongodb-org

Start and Enable MongoDB Service

systemctl start mongod
systemctl enable mongod

Check service status

systemctl status mongod

Output:

● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2026-02-11 15:22:10 UTC; 20s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 10444 (mongod)
   Memory: 100M
   CGroup: /system.slice/mongod.service
           └─10444 /usr/bin/mongod -f /etc/mongod.conf

Access MongoDB Shell

mongosh

Output:

Current Mongosh Log ID: 8ff3ab12991f42cc98112ac1
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true
Using MongoDB: 8.0.x
Using Mongosh: 2.5.8

Create MongoDB Admin User

Switch to admin database

use admin

Create admin user

db.createUser(
  {
    user: "Enter-A-user-Here",
    pwd: "Enter-A-Password-Here",
    roles: [ { role: "root", db: "admin" } ]
  }
)

List users

show users

Enable Authentication in MongoDB

Edit configuration file

vi /etc/mongod.conf

Add/modify security block

security:
  authorization: enabled

Restart MongoDB

systemctl restart mongod

Test without authentication

show users

Output:

MongoServerError: command usersInfo requires authentication

Authenticate

db.auth('Enter-A-user-Here', 'Enter-A-Password-Here')
exit

(Optional) Allow MongoDB in Firewall

firewall-cmd --zone=public --add-port=27017/tcp --permanent
firewall-cmd --reload

This completes the installation and configuration of MongoDB 8 on Rocky Linux 10.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS