MongoDB is a leading NoSQL document database that stores data as flexible JSON-like BSON documents. MongoDB 8 introduces improved aggregation performance, enhanced time series collections, and better sharding. This guide installs MongoDB 8 Community Edition on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS server
- A user with sudo privileges
- At least 1 GB RAM
Step 1 – Add the MongoDB Repository
sudo apt install gnupg curl -y
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc |
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ]
https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" |
sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
sudo apt update
Step 2 – Install MongoDB
sudo apt install mongodb-org -y
Step 3 – Start and Enable MongoDB
sudo systemctl start mongod
sudo systemctl enable mongod
sudo systemctl status mongod
Step 4 – Connect to the MongoDB Shell
mongosh
Step 5 – Create an Admin User
use admin
db.createUser({
user: "adminUser",
pwd: "SecureAdminPass2026!",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
})
exit
Step 6 – Enable Authentication
sudo nano /etc/mongod.conf
Add or uncomment:
security:
authorization: enabled
sudo systemctl restart mongod
Step 7 – Test Authenticated Login
mongosh -u adminUser -p --authenticationDatabase admin
Conclusion
MongoDB 8 is now installed and secured on Ubuntu 26.04 LTS. Use the MongoDB shell or MongoDB Compass (GUI) to manage your document databases. Pair with Mongoose (Node.js) or PyMongo (Python) for application development.