Install MongoDB on Ubuntu

MongoDB is a JSON-like cross-platform document-oriented database with dynamic schemas which MongoDB calls BSON.

Before we can type in the commands listed, we will need to open a terminal window

Click on the Ubuntu icon on the upper left and then type terminal to search for it. You can then launch it by clicking on it.

Accessing Ubuntu Terminal

Import the public key used by the package management system

Ubuntu 14.04:

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

Ubuntu 16.04:

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

Create a list file for MongoDB

Ubuntu 14.04:

echo “deb Index of ubuntu trusty/mongodb-org/3.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Ubuntu 16.04:

echo “deb [ arch=amd64,arm64 ] Index of ubuntu xenial/mongodb-org/3.6 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

Once that completes …

Reload the local Ubuntu package database

Ubuntu 14.04:

sudo apt-get update

Ubuntu 16.04:

sudo apt update

Start the install for MongoDB

Ubuntu 14.04:

sudo apt-get install -y mongodb-org

Ubuntu 16.04:

sudo apt install -y mongodb-org

Now to start MongoDB with systemctl.

sudo systemctl start mongod

Originally tested using MongoDB 3.26 on Ubuntu 14.04

Updated and tested using MongoDB 3.6 on Ubuntu 16.04