How to install MongoDB 5.0 Server on Debian 11 Bullseye

Learn the simple steps to install MongoDB server and client on Debian 11 to manage local or remote Databases with the help of a command terminal.

MongoDB is a database based on a non-relational document model. As a so-called NoSQL database (NoSQL = Not-only-SQL) it differs fundamentally from conventional relational databases such as Oracle, MySQL, or the Microsoft SQL Server. The name MongoDB is derived from the English word “humongous”, which roughly means “gigantic”.

MongoDB Server & client installation on Debian 11 or 10 Linux

During this article, the official repository of MongoDB is available for Debian 11 Bullseye, hence we can use the same.

1. Add MongoDB Repository on Debian 11

As we know the MongoDB packages are not available to install directly from the base repository of Debian 11 or 10., therefore, we need to add the official one offered by the developers of this NoSQL database.

echo "deb bullseye/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

2. Integrate the MongoDB GPG key

To ensure the packages we will receive to install this database on our Linux are from an authentic source. Add the GPG signed key by the developers of the Database server.

curl -sSL  -o mongoserver.asc
gpg --no-default-keyring --keyring ./mongo_key_temp.gpg --import ./mongoserver.asc
gpg --no-default-keyring --keyring ./mongo_key_temp.gpg --export > ./mongoserver_key.gpg
sudo mv mongoserver_key.gpg /etc/apt/trusted.gpg.d/


3. Run system update

On your Debian 11 or 10 command terminal run the system update command to make sure all the existing packages are up to date.

sudo apt update


4. Command to Install MongoDB on Debian 11 or 10

That’s it. We have configured already what we need to install “database-tools, mongosh, extra tools, mongos; database server and shell” on our Debian 11 or 10 Linux.

Hence, just run a simple command:

sudo apt install mongodb-org


5. Start and Enable MongoDB service

Once the installation is completed, let’s enable and also start the service of the Database server, so that we don’t need to run it again and again with system boot.

sudo systemctl enable --now mongod

to check the status:

sudo systemctl status mongod

Start MongoDB service on Debian 11


6. Check the installed version

To confirm what version is exactly installed on your system, run:

mongod --version

Command to check mongo database server version


To get the mongo command line simply type:


Whereas to know- how to use the database commands, see the official documentation. 


Uninstall or Remove

Well, those who are not interested anymore in MongoDB and don’t require it, can remove the same using the below-given command:

sudo apt remove mongodb-org


Other Articles:

Install MongoDB Compass GUI in Ubuntu 20.04 LTS Linux
How to install MariaDB 10 on Debian 11 Bullseye Linux
Install Chrome browser on Debian 11 Bullseye Linux




4 thoughts on “How to install MongoDB 5.0 Server on Debian 11 Bullseye”

  1. This procedure does not work with the following error

    The following packages have unmet dependencies:
    mongodb-org-tools : Depends: mongodb-database-tools but it is not installable
    E: Unable to correct problems, you have held broken packages.

  2. After sudo systemctl status mongod it failed to start. Any ideas? After starting, the session closes one second later (see auth.log). I’m far from an expert in linux and could use some assistance. Thanks!

    ● mongod.service – MongoDB Database Server
    Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset>
    Active: failed (Result: signal) since Sat 2022-10-01 12:47:10 PDT; 22s ago
    Process: 3883 ExecStart=/usr/bin/mongod –config /etc/mongod.conf (code=kil>
    Main PID: 3883 (code=killed, signal=ILL)
    CPU: 6ms

    The auth.log
    D=/usr/sbin/service mongod start
    Oct 1 12:47:09 debian11 sudo: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
    Oct 1 12:47:10 debian11 sudo: pam_unix(sudo:session): session closed for user root
    Oct 1 12:47:32 debian11 sudo: todd : TTY=pts/0 ; PWD=/home/todd ; USER=root ; COMMAND=/usr/bin/systemctl status mongod
    Oct 1 12:47:32 debian11 sudo: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.