Menu

How to Install MongoDB 8.0 on Debian 12 (Bookworm)

Install MongoDB 8.0 Community Edition on Debian 12 (Bookworm) amd64 from MongoDB’s signed APT repository and verify mongod with mongosh.

Posted on By Updated on
On this page

MongoDB 8.0 Community Edition supports Debian 12 (Bookworm) on 64-bit x86 (amd64). Debian 12 is now in Long Term Support (LTS) through June 30, 2028; see the Debian release information and MongoDB’s Debian installation guide for current details.

Debian’s separate mongodb package is not maintained by MongoDB and conflicts with the official mongodb-org packages. If it is installed, remove it before proceeding. If this system already contains MongoDB data, make and verify a backup before replacing packages.

Prerequisites

  • Debian 12 (Bookworm) on amd64.
  • A user account with sudo privileges.
  • Internet access.
  • A fresh MongoDB installation, or a verified backup and upgrade plan for any existing data.

Add MongoDB’s APT Repository

Install gnupg and curl if they are not already available:

sudo apt-get update
sudo apt-get install -y gnupg curl

Import MongoDB’s public signing key into an APT keyring:

curl -fsSL https://pgp.mongodb.com/server-8.0.asc | \
  sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

Add the MongoDB 8.0 repository for Debian 12:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | \
  sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

Refresh APT’s package index and check that mongodb-org is available from MongoDB’s repository:

sudo apt-get update
apt-cache policy mongodb-org

The candidate should be an 8.0 release from repo.mongodb.org. MongoDB publishes maintenance updates within the 8.0 series, so the patch version may change.

Install MongoDB Community Edition

Install the official metapackage and its components:

sudo apt-get install -y mongodb-org

Start and Verify MongoDB

Enable the mongod service at boot and start it:

sudo systemctl enable --now mongod

Check the service status and query the server version:

sudo systemctl status mongod --no-pager
mongosh --quiet --eval 'db.version()'

Connect to the local server with the MongoDB Shell:

mongosh

Manage the MongoDB Service

Use systemctl to manage the server:

sudo systemctl start mongod
sudo systemctl stop mongod
sudo systemctl restart mongod
sudo systemctl status mongod --no-pager

Troubleshooting

  • If APT cannot find mongodb-org, run sudo apt-get update and check that /etc/apt/sources.list.d/mongodb-org-8.0.list names the bookworm/mongodb-org/8.0 repository and amd64 architecture.
  • If mongod does not start, check sudo systemctl status mongod --no-pager and review recent service logs with sudo journalctl -u mongod -e --no-pager.
  • MongoDB binds to localhost by default. Before allowing remote connections, configure authentication and network controls as described in MongoDB’s production notes.

Conclusion

You installed MongoDB 8.0 Community Edition on Debian 12 from MongoDB’s signed APT repository, started mongod, and verified the server version. For Ubuntu 22.04 and 24.04, see our Ubuntu 22.04 guide and Ubuntu 24.04 guide. You can also browse the MongoDB Reference.