How to Install MongoDB Community Edition on Debian 10 Buster

MongoDB is a free and open-source document database. The software is characterized as a NoSQL database, a tool for storing JSON, or maybe even a Document Database.

Some features and advantages include:

  • Flexible document schemas
  • Code-native data access
  • Change-friendly design
  • Powerful querying and analytics
  • Easy horizontal scale-out

In the guide below, we will explain how to install MongoDB Community Edition on Debian 10, Buster. This version is the up to date version from MongoDB developers that is stable.


You will need root access or sudo privileges on your user account to perform the installation. You will need to make sure your Debian 10 operating system is up to date by typing the following.

sudo apt update && sudo apt upgrade -y

Next, install required packages for MongoDB manual installation.

sudo apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl -y


Download MongoDB

Now install the required MongoDB GPG key by executing the following.

curl -fsSL | sudo apt-key add -

Note, currently MongoDB is at version 4.4, but this may change. Visit the distribution page for Debian 10 Buster to verify the latest version for the GPG key and download package.

Next, you will download the package.

sudo add-apt-repository 'deb buster/mongodb-org/4.4 main'

Install MongoDB

Once downloaded, proceed to update the newly added repository and install. Type “Y” when prompted.

sudo apt update && sudo apt install mongodb-org

Example output:

Reading package lists… Done
 Building dependency tree       
 Reading state information… Done
 The following additional packages will be installed:
   mongodb-database-tools mongodb-org-database-tools-extra mongodb-org-mongos
   mongodb-org-server mongodb-org-shell mongodb-org-tools
 The following NEW packages will be installed:
   mongodb-database-tools mongodb-org mongodb-org-database-tools-extra
   mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
 Need to get 102 MB of archives.
 After this operation, 202 MB of additional disk space will be used.
 Do you want to continue? [Y/n] 

The following packages will be installed as part of the MongoDB-org package.

  • mongodb-org-server – The mongodb server daemon.
  • mongodb-org-mongos – The mongodb mongos daemon.
  • monodb-org-shell – The mongodb shell.
  • monodb-org-tools – Contains tools for importing, exporting and other utilities.


Status Check MongoDB

Check the status before you continue to make sure MongoDB is working. By default, it should be started. However, if the database software is not enabled or started, execute the following commands.

sudo systemctl status 

The output should be:

debian 10 buster mongodb status ok

The following commands you can exercise with starting, stopping, reloading the database.

start mongodb
 sudo systemctl start mongodb
 stop mongodb
 sudo systemctl stop mongodb
 reload mongodb
 sudo systemctl reload mongodb
 restart mongodb
 sudo systemctl restart mongodb
 enable on start up
 sudo systemctl enable
 disable on start up
 sudo systemctl disable

Test the database connection by doing a test connect by typing.

mongo --eval 'db.runCommand({ connectionStatus: 1 })'

Example output:

MongoDB shell version v4.4.6
 connecting to: mongodb://
 Implicit session: session { "id" : UUID("09f11c53-605f-44ad-abec-ec5801bb6b06") }
 MongoDB server version: 4.4.6
     "authInfo" : {
         "authenticatedUsers" : [ ],
         "authenticatedUserRoles" : [ ]
     "ok" : 1

Configuration MongoDB

You need to modify the MongoDB configuration file. This is named mongod.conf and is located in the /etc directory. You will uncomment the security section, or else any users on the system will access any database and perform any actions, leaving the databases more exposed to possible attacks.

Open the mongod.conf file using nano editor:

sudo nano /etc/mongod.conf

Next, uncomment the following line:

   authorization: enabled

Once complete, perform a restart.

sudo systemctl restart mongod


Create Admin User on MongoDB

The fact you enabled authorization enabled means you now need to make an admin user account. You do this by calling the database up with the following command.


Now inside MongoDB shell, connect to admin’s database.

use admin

Example output:

switched to db admin

Next, type the following to create a new Admin user. For our guide, we will call the user admin-mongodb.

     user: "admin-mongodb", 
     pwd: "$$$$PASSWORDCHANGE$$$$", 
     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]

Once you hit enter, you should receive the following output.

Successfully added user: {
     "user" : "admin-mongodb",
     "roles" : [
             "role" : "userAdminAnyDatabase",
             "db" : "admin"

Now you can exit MongoDB with the following.


Test MongoDB

In the final part, you will now test to make sure you have correctly set up the admin account. First, enter the MongoDB shell.

use admin

The output should be:

enter password

 switched to db admin

Now, once connected, we will list the users and databases they are connected to.

show users

Example output:

     "_id" : "admin.mongoAdmin",
     "userId" : UUID("cdc81e0f-db58-4ec3-a6b8-829ad0c31f5c"),
     "user" : "admin-mongodb",
     "db" : "admin",
     "roles" : [
             "role" : "userAdminAnyDatabase",
             "db" : "admin"
     "mechanisms" : [


Updating MongoDB

Updates are done with the standard terminal command sudo apt update as you added the repository in your sources. In the list, you do not need to manually re-download updates.

Congratulations, you have now finished installing and configuring MongoDB for Debian 10.

Comments and Conclusion

The guide has successfully shown you how to download the Community Edition of MongoDB. One single main benefit MongoDB has over MySQL is its ability to handle extensive unstructured data. It is magically faster. The popularity of Mongo is rising and should be looked into for any practical development projects that require databases.

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x