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.
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
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:
And to stop MongoDB:
sudo systemctl stop mongod
Good job! by reaching this point, you learned how to install MongoDB 4 on Debian 10.
Dear user, we wish this tutorial would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.
Do not miss the related article: