How to Install MongoDB on Ubuntu 16.04 OS?

  1 year ago     Views:  1197  
Jitesh Meniya
2 Follows

In this article, we will share with you how to install MongoDB in ubuntu. MongoDB is one of the open-source database and currently most used in modern web applications for high performance. MongoDB is JSON based database you can use MongoDB in most off programing language but it mostly uses with nodejs.

We are here show you all installation process step by step so, please follow this step and easily configure and install MongoDB in your local system.

Step - 1 : Adding the MongoDB Repository

Before installing MongoDB you should install these repositories for a new updated version, in ubuntu is already included. simply run following command in your Ubuntu terminal.

sudo apt-key adv --keyserver hkp:// --recv EA312927

After running this command you make sure you get the following output in the terminal.

Executing: /tmp/tmp.3JTuFvsumc/ --keyserver
gpg: requesting key EA312927 from hkp server
gpg: key EA312927: public key "Totally Legit Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Now run following command.

sudo apt-get update

Step - 2 : Installing and Verifying MongoDB

Now, run the following command to install MongoDB.

sudo apt-get install -y mongodb-org
sudo apt-get install mongodb

This command will install the latest several packages for MongoDB.

After doing this process then go this directory root /etc/systemd/system/ and run the following command.

sudo nano /etc/systemd/system/mongodb.service

When you run this command then mongodb.service file open in ubuntu's nano editor and you show output looks like this.

Description=High-performance, schema-free document-oriented database

ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf


Next, start the newly created service with systemctl.

sudo systemctl start mongodb

After running this command then check systemctl status this started properly or not using the following command.

sudo systemctl status mongodb

Then check your output look like this.

● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-12-16 12:25:28 IST; 4min 4s ago
     Docs: man:mongod(1)
 Main PID: 13931 (mongod)
   CGroup: /system.slice/mongodb.service
           └─13931 /usr/bin/mongod --config /etc/mongodb.conf

Dec 16 12:25:28 dell-Vostro-15-3568 systemd[1]: Started An object/document-oriented database.
Dec 16 12:29:21 dell-Vostro-15-3568 systemd[1]: Started An object/document-oriented database.

Now check your MongoDB is installed successfully or not. so, simple check MongoDB version run by the following command.

mongod --version

After running this command you show something that look like the output in your terminal.

db version v2.6.10
2019-12-16T12:31:13.714+0530 git version: nogitversion
2019-12-16T12:31:13.714+0530 OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016


You can see Install the MongoDB in Ubuntu is very easy. You can check I hope you will like this article. Also please follow us on Twitter and Like our Facebook page for updates.

Was this article helpful?

0 out of 0 person found this article helpful.

Leave a comment


No Comments