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://keyserver.ubuntu.com:80 --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 http://repo.mongodb.org/apt/debian 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 http://deb.debian.org/debian/ 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.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

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

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.