MongoDB is a high-performance, document-oriented NoSQL database used to handle high traffic and large volumes of data. It is written in the C ++ programming language and is available for the Windows, Mac OS X, and Linux operating systems. Instead of using NoSQL, MongoDB stores the data in JSON format. This means you can store your records without worrying about the data structure such as the number of fields or types of fields to store values. It is a highly scalable, flexible, and distributed NoSQL database.

In this post, we will show you how to install MongoDB on Rocky Linux 10.

Prerequisites

  • A server running Rocky Linux 10 on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux 10 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install MongoDB

By default, the MongoDB package is not included in the Rocky Linux 10 default repo, so you will need to create a MongoDB repo in your system. You can create it using the following command:

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

Add the following lines:

[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/7.0/x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0

Save and close the file, then install the MongoDB package using the following command:

dnf install mongodb-org

After the installation, start and enable the MongoDB service with the following command:

systemctl start mongod
systemctl enable mongod

You can check the status of MongoDB using the following command:

systemctl status mongod

Sample output:

ā— mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; preset: disabled)
Active: active (running) since Sun 2025-10-19 23:39:25 EDT; 1min 29s ago
Invocation: 691134383ce344259fdf55e2885fd2f0
Docs: https://docs.mongodb.org/manual
Main PID: 44002 (mongod)
Memory: 174.8M (peak: 263.2M)
CPU: 1.493s
CGroup: /system.slice/mongod.service
└─44002 /usr/bin/mongod -f /etc/mongod.conf

Now, verify the MongoDB version using the following command:

mongod --version

Sample output:

db version v7.0.25
Build Info: {
"version": "7.0.25",
"gitVersion": "96dce3da49b8d2e9e0d328048cb56930eb1bdb2b",
"openSSLVersion": "OpenSSL 3.2.2 4 Jun 2024",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "rhel90",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}

Step 3 – How to Use MongoDB

You can connect to the MongoDB shell using the following command:

mongosh

After connected, run the following command to list all databases:

> db

Sample output:

test

Next, create a new database named admin using the following command:

> use admin

To create a collection and insert some data, run the following command:

> db.linux.insertOne(
  { "RockyLinux" : "10",
   "centos" : "9",
   "debian" : "12"
  }
)

To verify the collection, run:

> show collections

Sample output:

linux

To display your data, run:

> db.linux.find()

Sample output:

{ "_id" : ObjectId("6165aa323a2df0ac96aa216a"), "RockyLinux" : "10", "centos" : "9", "debian" : "12" }

Step 4 – Enable MongoDB Authentication

By default, MongoDB is connected without login, so it is a good idea to enable authentication in MongoDB.

First, log in to MongoDB with the following command:

mongosh

Next, create a MongoDB admin user and set a password:

> use admin
> db.createUser(
  {
    user: "mongoadmin",
    pwd: "password",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

Sample output:

Successfully added user: {
	"user" : "mongoadmin ",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "admin"
		}
	]
}

To verify your users, run:

> db.getUsers()

Sample output:

[
	{
		"_id" : "admin.mongoadmin ",
		"userId" : UUID("ba2efd4e-84eb-4000-9d27-c0c337b4d7d8"),
		"user" : "mongoadmin ",
		"db" : "admin",
		"roles" : [
			{
				"role" : "readWrite",
				"db" : "admin"
			}
		],
		"mechanisms" : [
			"SCRAM-SHA-1",
			"SCRAM-SHA-256"
		]
	}
]

Next, edit the MongoDB configuration file and enable authentication:

nano /etc/mongod.conf

Add the following line:

security:
   authorization: enabled

Save and close the file, then restart the MongoDB service to apply the changes:

systemctl restart mongod

You can now connect to the MongoDB by specifying a user and password as shown below:

mongosh -u mongoadmin -p

Step 5 – Uninstall MongoDB

If you want to remove the MongoDB from your system, first stop the MongoDB service:

systemctl stop mongod

Next, remove the MongoDB package by running the following command:

dnf remove mongodb-org

Next, remove the MongoDB logs and data directories by running the following command:

rm -rf /var/lib/mongodb

Conclusion

In the above guide, we explained how to install MongoDB on RockyLinux 10. We also explained how to use MongoDB and enable authentication in MongoDB. Give it a try on your dedicated server from Atlantic.Net!