How to Install MongoDB on Debian 10

Install MongoDB on Debian 10

In this article, we will have explained the necessary steps to install and configure Install MongoDB on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

MongoDB is an open-source NoSQL database written in C++ for massive scalability, high performance, and availability. It stores data in JSON-like documents and supports Ad hoc queries, indexing, and real-time aggregation.

Install MongoDB on Debian 10

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install MongoDB.

First, add MongoDB repository:

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

To install MongoDB 4, you have to run the following command:

sudo apt update
sudo apt install libcurl3
sudo apt install mongodb-org
sudo apt install mongodb-org-server

Once the installation is completed, start the MongoDB daemon and enable it to start on boot by typing:

sudo systemctl start mongod
sudo systemctl enable mongod

Finally, use the below command to check the installed MongoDB version on your system:

mongod --version

Also, connect MongoDB using the command line and execute some test commands for checking proper working:

[email protected]:~$ mongo

> use mydb;

> { tecadmin: 100 } )

> db.test.find()

  { "_id" : ObjectId("52b0dc828bmwe46071cbb5daf"), "linuxtips" : 100 }

That’s all you need to do to install MongoDB on Debian 10 Buster. I hope you find this quick tip helpful. For further reading on MongoDB, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.