How to Install MongoDB on Ubuntu 16.04


Today, Laravelcode share with you how to install mongodn in ubuntu. mongodb is one of the open source database and currentlly most used in morder web application for high performance. mongodb is json based database you can use mongodb in most off programing language but it mostlly use with nodejs.

We are here show you all installation proccess step by step so, please follow this step and easyly configure and install mongodb in your local system.

Step : 1 Adding the MongoDB Repository

Before install mongodb you should install this repositories for new updated version, in ubuntu is already inculed. simply run following command in your ubuntu terinal.

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

After run this commant you make sure you getting following output in teminal

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

Now run following command

sudo apt-get update

Step : 2 Installing and Verifying MongoDB

Now, run following command for install mongodb

sudo apt-get install -y mongodb-org

This command will install letest sevrel packages for mongodb.

After done this proccess then go this directory root /etc/systemd/system/ and run following command.

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

When you run this command then mongodb.service file open in ubuntu's nano editer and you show output look 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 run this command then check systemctl status this started properly or not using following command.

sudo systemctl status mongodb


Then check your output look like this.

● mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-04-25 14:57:20 EDT; 1min 30s ago
 Main PID: 4093 (mongod)
    Tasks: 16 (limit: 512)
   Memory: 47.1M
      CPU: 1.224s
   CGroup: /system.slice/mongodb.service
           └─4093 /usr/bin/mongod --quiet --config /etc/mongod.conf

And last step for your mongodb automatic star when your system start. run following command.

sudo systemctl status mongodb

Now check your mongodb is install successfuly or not. so, simple check mongodb version run by following command.

mongod --version

After run this command you show somthing look like output in your terminal.

db version v3.2.12
git version: ef3e1bc78e997f0d9f22f45aeb1d8e3b6ac14a14
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

If you face any problem then please write a comment or give some suggestions for improvement. Thanks...