• Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
TecAdmin.net
  • Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
01 January 2016

How to Install MongoDB 3.6 on Ubuntu 16.04 & 14.04 via PPA

Written by Rahul K. | January 1, 2016
Databases, MongoDB install mongodb, mongo, mongodb, mongodb ubuntu, ubuntu mongodb

MongoDB (named from “huMONGOus“) is a full flexible index support and rich queries database. Mongodb is a NoSQL database. MongoDB provides large media storage with GridFS. Click here for more details about this version of MongoDB.

This tutorial will help you to install MongoDB 3.6 Production Release on Ubuntu 16.04 LTS (Xenial), 14.04 LTS (trusty) and Ubuntu 12.04 LTS (Precise).

Step 1 – Setup Apt Repository

First of all, import GPK key for the MongoDB apt repository on your system using the following command. This is required to test packages before installation

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Lets add MongoDB APT repository url in /etc/apt/sources.list.d/mongodb.list.

For Ubuntu 16.04:
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
For Ubuntu 14.04:
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

Step 2 – Install MongoDB Server

After adding required APT repositories, use following commands to install MongoDB on your systems. It will also install all dependent packages required for MongoDB.

sudo apt-get update
sudo apt-get install mongodb-org

If you want to install any specific version of MongoDB, define the version number as below

sudo apt-get install mongodb-org=3.6.3 mongodb-org-server=3.6.3 mongodb-org-shell=3.6.3 mongodb-org-mongos=3.6.3 mongodb-org-tools=3.6.3

Step 3 – Manage MongoDB Service

After installation, MongoDB will start automatically. To start or stop MongoDB use init script. Below are the example commands to do.

sudo systmectl enable mongod
sudo systmectl start mongod 

Use the following commands to stop or restart MongoDB service.

sudo systmectl stop mongod
sudo systmectl restart mongod 
  • How to Create and Drop Users in MongoDB

Step 4 – Verify MongoDB Installation

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

mongod --version 

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

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

mongo 

> use mydb;

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

> db.test.find()

  { "_id" : ObjectId("52b0dc8285f8a8071cbb5daf"), "tecadmin" : 100 }
  • How to Create and Drop database in MongoDB

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul K.
Rahul K.
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Install MongoDB Server 3.4 on Debian 8/7

  • How to Create and Drop Users in MongoDB

  • How to Install MongoDB 3.4 on CentOS/RHEL 7/6, Fedora 27/26/25

  • How to Backup, Restore and Migrate MongoDB Database

  • How to Setup Node.js with MongoDB on CentOS, RHEL

15 Comments

  1. codeasearch Reply to codeasearch
    March 12, 2018 at 8:03 pm

    nice tutorial dude, thanks for sharing. because of you i am able fix the connective issue in mongodb server

  2. Raihan Reply to Raihan
    February 19, 2016 at 8:30 am

    Please help me , I can not install mongodb 🙁

    sudo apt-get install -y mongodb-org
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package mongodb-org

  3. Andrew Soloninka Reply to Andrew
    January 22, 2016 at 10:37 pm

    I am running Linux Mint 17.1 which is based on Umbuntu 14.04. When I try to install, I get the following error:

    Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock directory /var/lib/apt/lists/

    when I run the command: sudo apt-get update

    • Anil Reply to Anil
      March 16, 2016 at 9:22 am

      delete /var/lib/apt/lists/lock file using
      sudo rm /var/lib/apt/lists/lock command and run the
      sudo apt-get update command. it willl work fine

  4. Sahil Reply to Sahil
    October 24, 2015 at 11:33 pm

    I am using Ubuntu 15.04. I have followed all the steps above and the installation was successful.
    But, when I try to start the service, I get an error:
    Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.

    • Satarupa Guha Reply to Satarupa
      December 24, 2015 at 1:09 pm

      Reply name to trusty instead of wily in this command:

      echo “deb http://repo.mongodb.org/apt/debian trusty/mongodb-org/3.0 main” | sudo tee /etc/apt/sources.list.d/mongodb.list

      Also install upstart by
      sudo apt-get install upstart-sysv

      Redo everything from scratch.

  5. Pumpkin Reply to Pumpkin
    October 20, 2015 at 7:20 am

    This ‘tutorial’ is not gonna work for Debian Jessie, since it is using systemd and not the old sysvinit.
    Mongo has as yet not released a package for systemd.
    Creating a mongod.service yourself is not difficult, but I still experience issues with starting the service at boot…

    • Max Reply to Max
      March 18, 2016 at 10:18 am

      Hi Pumpkin,

      How did you do then ? My server is based on Debian “Jessie”, and I can’t find a way to install MongoDB properly.
      No tutorials on internet, and I’m afraid to install those recommended by MongoDB-org.

      Did you find any solution ? Or any web site to recommend ?
      Cheers,

      Max

  6. Salim Reply to Salim
    October 7, 2015 at 5:37 am

    This tutorial is working for debian weezy or raspberry pi?

  7. Lorenzo Reply to Lorenzo
    May 28, 2015 at 8:04 am

    Hi,
    thank you for this tutorial, but there is a problem when installing Mongo on Ubuntu 14.10 because doesn’t exists the Mongo repository for 14.10 version.

    Could you help me to resolve this problem?

    Thanks.

    • Vitali Reply to Vitali
      June 26, 2015 at 5:14 pm

      Hi Lorenzo,

      I had the similar problem on Linux Mint 17.2. I fixed that by editing the mongodb repository in the source list. You need to replace the Unbuntu’s 14.10 name to 14.04 which is trusty. My final repo looks like this:

      deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse

      Hope that helps,
      Vitali

  8. Rakesh P Nehete Reply to Rakesh
    April 24, 2015 at 12:42 pm

    Very nice site always help full .Nice resolution .
    Thank you very much Rahul

  9. Rakesh Reply to Rakesh
    April 24, 2015 at 12:40 pm

    very nice site always helpful.

  10. Divya Reply to Divya
    May 15, 2014 at 8:24 am

    How to run and connect mongo db in browser just like for mysql we use localhost/phpmyadmin. Any suggestions will be helpful

    • Rahul K. Rahul Reply to Rahul
      May 15, 2014 at 10:19 am

      Hi Divya

      You can download phpmoadmin. I will be helpful for you.

      http://www.phpmoadmin.com/file/phpmoadmin.zip

Leave a Reply

Cancel reply

Popular Posts

  • How to Install JAVA 8 on Ubuntu 18.04/16.04, LinuxMint 18/17
  • How to Install s3cmd in Linux and Manage Amazon s3 Buckets
  • How to Install AnyDesk on Ubuntu, Debian and LinuxMint (Alternative of TeamViewer)
  • How to Setup Selenium with ChromeDriver on Ubuntu 16.04
  • How to Install MySQL on macOS Sierra and High Sierra
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services