How to Install MongoDB on AlmaLinux 10

How to install MongoDB in Debian 13

MongoDB is a document-based database first developed by MongoDB Inc. in 2007. It is an example of a NoSQL database, meaning it doesn’t use a table structure like a relational database, but instead stores data in a flexible document format (such as JSON). Each document in MongoDB can have a different structure, making it ideal for data that lacks a fixed schema or is large and diverse. MongoDB is a top choice for many modern technology companies due to its flexibility in handling diverse data and its ability to support applications that require high speed and scalability. In this article, we will show you how to install MongoDB on AlmaLinux 10.

Prerequisites

  • An AlmaLinux VPS
  • root SSH access or a regular user with sudo privileges

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

Step 1: Log in to Your Server

To start this, you will need to log in to your AlmaLinux 10 VPS via SSH as the root user:

ssh root@IP_Address -p Port_number

You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the system user with sudo privileges.

You can check whether you have the proper AlmaLinux version installed on your server with the following command:

# cat /etc/almalinux-release 

You will get an output like this:

AlmaLinux release 10.0 (Purple Lion)

In this article, we are using ‘root’ to execute the shell commands. If you want to use your regular user with sudo privileges to run the commands, make sure to append ‘sudo’ in front of them.

Step 2: Update the System

Before starting, you have to make sure that all AlmaLinux OS packages are up to date. You can do this by executing the following commands:

# dnf update
# dnf upgrade

Step 3. Add MongoDB Repository

AlmaLinux does not include MongoDB packages in its official repository, so we cannot simply install it. We can install MongoDB either as a Docker container or using the MongoDB repository. In this tutorial, we will show you how to install MongoDB from their repository. We need to add the MongoDB repository to our AlmaLinux 10 system now.

# nano /etc/yum.repos.d/mongodb-org.repo

Paste the following content into that file.

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

Step 4. Install MongoDB

At this point, we should be able to install MongoDB on our AlmaLinux 10. Let’s execute the command below to install it.

# dnf install mongodb-org -y

The command will download and install the MongoDB packages.

Once installed, MongoDB will not run automatically. We can invoke the command below to start it and ensure it starts upon server reboot.

# systemctl enable --now mongod

The MongoDB service should be up and running now. We can check it by running this command:

# systemctl status mongod

The command will print an output similar to this:

● mongod.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-08-16 10:25:48 UTC; 15min ago
 Invocation: 1308ba4bb294457dbf031e08694813ff
       Docs: https://docs.mongodb.org/manual
   Main PID: 1668 (mongod)
     Memory: 115.2M (peak: 115.6M)
        CPU: 5.754s
     CGroup: /system.slice/mongod.service
             └─1668 /usr/bin/mongod -f /etc/mongod.conf

Aug 16 10:25:48 almalinux10.rosehosting.com systemd[1]: Started mongod.service - MongoDB Database Server.
Aug 16 10:25:49 almalinux10.rosehosting.com mongod[1668]: {"t":{"$date":"2025-08-16T10:25:49.010Z"},"s":"I",  "c":"CONTROL",  "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CONFIG_OVERRIDE_NOF>

Step 5: Secure MongoDB

By default, MongoDB is not secure, which means anyone with access to the port can interact with your database. Let’s fix that by enabling authentication. First, open the MongoDB configuration file with a text editor:

# nano /etc/mongod.conf

Inside the file, look for the security section. If it’s commented out, remove the # symbol. If it doesn’t exist, add the following lines to enable user authentication:

security:
  authorization: "enabled"

This change requires users to log in with a username and password to access the database.

After you’ve saved your changes, restart the MongoDB service to apply them:

# systemctl restart mongod

Step 6. Create an Administrative User

Now that authentication is enabled, we need to create an administrative user to manage the database. First, connect to the MongoDB shell. If you’re on the same machine as the database, you can use a simple command like mongosh, or you may need to specify the connection details.

Once you’re in the shell, switch to the admin database, which is where you should create administrative users:

use admin

Next, create the user with a username and password. Remember to change m0d1fyth15 to something strong and unique.

db.createUser({
  user: "admin",
  pwd: "m0d1fyth15",
  roles: [{ role: "root", db: "admin" }]
})

This command creates a user named “admin” with root privileges, allowing them full control over all databases.

After the user is created, you can exit the MongoDB shell by typing:

exit

Now, to connect to MongoDB, you can use this command:

# mongosh -u admin -p m0d1fyth15 --authenticationDatabase admin

Congratulation! You have learned how to install MongoDB on AlmaLinux 10.

If you are one of our web hosting customers and use our managed AlmaLinux Hosting, you don’t have to follow this tutorial and install MongoDB on AlmaLinux 10 yourself; our experienced Linux admins will set up and configure a MongoDB VPS for you. They are available 24×7 and will take care of your request immediately. Simply submit a ticket. We will also help you install MongoDB on a Docker container if you prefer Docker to the traditional package installation method.

If you liked this post, please share it with your friends or leave a comment below.

Leave a Comment