Advance

How to install MongoDB 4 on Debian 10

How to install MongoDB 4 on Debian 10

In the following of Debian 10 tutorials, in this article, we are going to learn you how to Install MongoDB 4 on Debian 10. But first, what is MongoDB basically? MongoDB is an opensource, cross-platform NoSQL database server developed by MongoDB Inc. To store its data, it uses JSON. Also, it is popular for handling large amounts of data due to its scalability, high availability, and high performance.

 

How to Install MongoDB 4 on Debian 10

Let’s walk through the 5 steps of this guide to learn how to install MongoDB 4 on Debian 10 Linux distribution.

Recommended Article: How to setup a web server with a CWP hosting panel

1- Importing MongoDB GPG Key on Debian

First, import the GPG key that is required by the MongoDB repository for your Debian system. Please consider that this is crucial for testing packages prior to installation.

To update your system packages:

sudo apt update  

 

To import the MongoDB GPG key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4  

 

Buy Linux Virtual Private Server

 

2- Installing MongoDB 4 APT Repository on Debian

In case you can not find the official Package repositories for Debian 10, 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:

echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org.list  

 

And to add the official repository of Debian 9 on Debian 10 Buster:

echo "deb http://deb.debian.org/debian/ stretch main" | sudo tee /etc/apt/sources.list.d/debian-stretch.list  

 

Then, update the APT repository:

sudo apt update  

3- Installing libcurl3 on Debian

In this step, you see that the package libcurl3 is required by mongodb-org-server which you are going to install later on. the reason for installing libcurl3 is to prevent errors trying to install MongoDB.

Note: In this guide, we added Debian 9‘s official repository, the libcurl3 package will be installed from the added repository. But Debian 10 uses libcurl4.

To install libcurl3:

sudo apt install libcurl3  

 

4- Installing MongoDB 4 Server on Debian

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

sudo apt install mongodb-org -y  

 

Use the following command to check the version of MongoDB installed.

sudo apt info mongodb-info  

 

As the MongoDB runs on port 27017 by default, verify it by typing:

sudo netstat -pnltu  

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

 

5- Managing MongoDB 4 Server

Make sure you have successfully installed MongoDB 4 server, to let you start it.

sudo systemctl start mongod

 

To check the status of a MongoDB service:

sudo systemctl status mongod  

 

Then, to enable MongoDB to start on boot:

sudo systemctl enable mongod  

 

Next, to log into MongoDB 4 simply:

mongo  

 

And to stop MongoDB:

sudo systemctl stop mongod  

 

Good job! by reaching this point, you learned how to install MongoDB 4 on Debian 10.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day