Updated: 28 September 2026 · Applies to: Debian 12, Ubuntu 24.04, AlmaLinux 9 and Rocky Linux 9 (MongoDB 8.3)
Debian 8 and 9 are end of life. This guide installs MongoDB Community from MongoDB's official repository on Debian 12 (Ubuntu 24.04 and AlmaLinux 9 / Rocky Linux 9 are included too).
Install MongoDB Community (official repository)
MongoDB's documentation currently installs version 8.3. Ubuntu 24.04:
curl -fsSL https://pgp.mongodb.com/server-8.0.asc | 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.3 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.3.list apt update && apt install mongodb-org systemctl enable --now mongod
On Debian 12 the repository line is deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.3 main.
AlmaLinux 9 / Rocky Linux 9: create /etc/yum.repos.d/mongodb-org-8.3.repo:
[mongodb-org-8.3] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.3/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://pgp.mongodb.com/server-8.0.asc
Then run dnf install mongodb-org && systemctl enable --now mongod.
Note: MongoDB listens on 127.0.0.1 by default. Keep it that way, or enable authentication before opening it to other servers.
First steps
mongosh # the MongoDB shell
use shop
db.products.insertOne({ name: "VPS", price: 9.99 })
db.products.find()
exit
Enable authentication
- In
mongosh, create an admin:use admin, thendb.createUser({ user: "admin", pwd: passwordPrompt(), roles: ["root"] }). - In
/etc/mongod.confaddsecurity:withauthorization: enabledon the next line (indented). - Restart:
systemctl restart mongod, then log in withmongosh -u admin -p --authenticationDatabase admin.
Backup
mongodump --out /backup/mongo-$(date +%F) mongorestore /backup/mongo-2026-09-28
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
