Open-source MongoDB is the most popular document-oriented database management system. It is cross-platform and uses JSON-like documents with optional schemas. MongoDB is written in C++ and is used for developing mission-critical and modern dynamic applications. The data objects are stored as separate documents in a collection in the MongoDB database versus in a traditional relational database system, where rows and columns are used. It also offers an easy querying and indexing functionality that allows developers to query complex document-based data sets easily.
In this post, we will explain how to install and use MongoDB on Oracle Linux 10.
Step 1 – Create Atlantic.Net Cloud Server
First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Oracle 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 Oracle 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 Tue 2025-12-30 22:50:17 EST; 3s ago
Invocation: afbc54a6545d4bfba19fcc7fe0d44c26
Docs: https://docs.mongodb.org/manual
Main PID: 182814 (mongod)
Memory: 133.9M (peak: 134M)
CPU: 796ms
CGroup: /system.slice/mongod.service
āā182814 /usr/bin/mongod -f /etc/mongod.conf
Dec 30 22:50:17 oracle systemd[1]: Started mongod.service - MongoDB Database Server.
Dec 30 22:50:17 oracle mongod[182814]: {"t":{"$date":"2025-12-31T03:50:17.749Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CONFIG_OVERRI>
Now, verify the MongoDB version using the following command:
mongod --version
Sample output:
db version v7.0.28
Build Info: {
"version": "7.0.28",
"gitVersion": "cfc346c59d2cc3dbc903507fc642e22e3097f362",
"openSSLVersion": "OpenSSL 3.5.1 1 Jul 2025",
"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 this guide, we learned how to install and use the MongoDB database on Oracle Linux 10. We also learned how to enable MongoDB authentication and interact with a MongoDB database. You can now easily install and manage the MongoDB databases. Try it on dedicated hosting from Atlantic.Net!