MongoDB is a full flexible index support and rich queries database. It is a NoSQL database. MongoDB provides large media storage with GridFS. Click here for more details about this version of MongoDB. Use this tutorial to install MongoDB server 4.2 on Debian 10, Debian 9 Stretch and Debian 8 Jessie systems.

Advertisement

Prerequisites

You must have shell access with sudo privileded account to your Debian system.

Login to your system and open a shell.

Step 1 – Installing MongoDB on Debian

You need to execute following commands step by step to install MongoDB on Debian Linux systems.

  1. First of all, import MongoDB public GPG key in your system
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 656408E390CFB1F5
    
  2. Next, add MongoDB apt repository url to your Debian system.
    echo "deb http://repo.mongodb.org/apt/debian "$(lsb_release -sc)"/mongodb-org/4.2 main" | sudo tee /etc/apt/sources.list.d/mongo.list 
    
  3. Now, install the MongoDB server packages on Debian system.
    sudo apt update 
    sudo apt install mongodb-org 
    
  4. Press ‘y’ for any confirmation asked by the installer.

Step 2 – Manage MongoDB Service

MongoDB database server has been installed successfully on your system. Let’s execute the below command to start MongoDB servie.

sudo systemctl start mongod.service 

Also, run the below command to enable MongoDB to start on system boot.

sudo systemctl enable mongod.service 

Step 3 – Test MongoDB Version

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

mongod --version 

db version v4.2.1
git version: edf6d45851c0b9ee15548f0f847df141764a317e
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019
allocator: tcmalloc
modules: none
build environment:
    distmod: debian92
    distarch: x86_64
    target_arch: x86_64

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

rahul@tecadmin:~$ mongo

> use mydb;

> db.test.save( { tecadmin: 100 } )

> db.test.find()

  { "_id" : ObjectId("52b0dc8285f8a8071cbb5daf"), "tecadmin" : 100 }
Share.

9 Comments

  1. Please don not mislead people! If you go the the MongoDB repo(http://repo.mongodb.org/apt/debian) and click on ‘dists’, you won’t see the ‘buster’ version of it yet. Now from where on earth would Debian Debian be downloading the ‘buster’ release?
    Additionally, libcurl3 is replaced by libcurl4. So, ‘stretch’ version of MongoDB won’t work either.

    Please do not put such titles.

    (date: 28/07/2019)

  2. Doesn’t work on Debian 10, there is no release for buster as of yet. The title of this article is a lie…

    • No, there is not, the problem it’s the library libcurl3, that it’s depreciated in debian 10, and still be on use on the package mongo-server, i think it’s a good idea to make a fork of the code and try to solve it 😛

      • No, the probleem is not libcurl3. The problem is if you try to install it, it refers to unavailable mongodb-org-server package. So “Reader” is right, this article is not usable for Debian 10.

  3. Thanks for the great article! I have been trying to get MongoDB 4.0 up and running on Raspberry Pi 3 B+ which has ARM64 architecture but have not been able to even after spending countless hours. Would you Be able to help me do it?


Exit mobile version