How to Install MongoDB 4 on Debian 10

MongoDB is an opensource, cross-platform NoSQL database server that developed by MongoDB Inc. It uses JSON to store its data and is popular for handling large amounts of data due to its scalability, high availability, and high performance.

In this tutorial, you will learn how to install MongoDB 4 on Debian 10 Linux distribution.

Step 1: Importing MongoDB GPG Key on Debian

To start off, you need to import the GPG key that is required by the MongoDB repository for your Debian system. This is crucial for testing packages prior to installation.

First, update your system packages using the following apt command.

$ sudo apt update
Update Debian 10 Buster

Update Debian 10 Buster

To import the MongoDB GPG key, run the command.

$ sudo apt-key adv --keyserver hkp:// --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Add MongoDB Repository Key

Add MongoDB Repository Key

With that done, now add the MongoDB APT repository on your Debian system as explained below.

Step 2: Installing MongoDB 4 APT Repository on Debian

At the time of penning down this article, MongoDB 4 does not have official Package repositories for Debian 10. But worry not. You can still add the package repository of Debian 9 (Stretch) on Debian 10 (Buster) to make up for that.

To add MongoDB 4 package repository of Debian 9 on Debian 10 Buster, execute the command.

$ echo "deb stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org.list

To add the official repository of Debian 9 on Debian 10 Buster, issue the command.

$ echo "deb stretch main" | sudo tee /etc/apt/sources.list.d/debian-stretch.list
Add MongoDB Repository on Debian

Add MongoDB Repository on Debian

Next, update the APT repository using the command.

$ sudo apt update
Update APT Repository

Update APT Repository

Step 3: Installing libcurl3 on Debian

The package libcurl3 is required by mongodb-org-server which we are going to install later on. Without libcurl3, you will encounter errors trying to install MongoDB.

It is also worth mentioning that Debian 10 uses libcurl4, but since we added Debian 9‘s official repository, the libcurl3 package will be installed from the added repository.

To install libcurl3, run the command.

$ sudo apt install libcurl3
Install libcurl3 on Debian

Install libcurl3 on Debian

Step 4: Installing MongoDB 4 Server on Debian

Having installed the required repositories and libcurl3 package, you can now proceed to install MongoDB 4 server.

$ sudo apt install mongodb-org -y
Install Mongodb Server on Debian

Install MongoDB Server on Debian

To check the version of MongoDB installed issue the APT command as shown.

$ sudo apt info mongodb-info
Check MongoDB Version

Check MongoDB Version

By default, MongoDB runs on port 27017 and you can verify it using the netstat command as shown.

$ sudo netstat -pnltu
Check MongoDB Port

Check MongoDB Port

To change the default MongoDB port and other parameters, edit the configuration file found at /etc/mongodb.conf.

Change MongoDB Default Port

Change MongoDB Default Port

Step 5: Managing MongoDB 4 Server

Once you have successfully installed MongoDB 4 server, start it using the command.

$ sudo systemctl start mongod

To check the status of a MongoDB service run the command.

$ sudo systemctl status mongod
Check MongoDB Status

Check MongoDB Status

To enable MongoDB to start on boot, run the command.

$ sudo systemctl enable mongod

To log into MongoDB 4 simply run the command.

$ mongo
Access MongoDB Shell

Access MongoDB Shell

To stop MongoDB run.

$ sudo systemctl stop mongod

And that’s just about it. In this guide, we have demonstrated how you can install MongoDB 4 on Debian 10.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

James Kiarie

This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

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