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

  1. In mongosh, create an admin: use admin, then db.createUser({ user: "admin", pwd: passwordPrompt(), roles: ["root"] }).
  2. In /etc/mongod.conf add security: with authorization: enabled on the next line (indented).
  3. Restart: systemctl restart mongod, then log in with mongosh -u admin -p --authenticationDatabase admin.

Backup

mongodump --out /backup/mongo-$(date +%F)
mongorestore /backup/mongo-2026-09-28

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)