How to Install MongoDB 4.2 on Debian 10/9/8

How to Install MongoDB 4.2 on Debian 10/9/8

 

How to Install MongoDB 4.2 on Debian 10/9/8


MongoDB is a fully 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.

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 the following commands step by step to install MongoDB on Debian Linux systems.

  1. First of all, import the MongoDB public GPG key into 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 the 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 }
Reactions

Post a Comment

0 Comments

close