How to Install MongoDB 8 on AlmaLinux 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

Before installing MongoDB, manually add its repository because it is not available in the default AlmaLinux 10 repository.

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 Tue 2026-01-20 14:32:10 UTC; 20s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 10520 (mongod)
   Memory: 99.5M
   CGroup: /system.slice/mongod.service
           └─10520 /usr/bin/mongod -f /etc/mongod.conf

Access MongoDB Shell

mongosh

Output:

Current Mongosh Log ID: 1b23cd098b2f4bc17dd21ab5
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 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 AlmaLinux 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