Install Mongo Ubuntu

Install Mongo Ubuntu

by John Vincent

Posted on March 01, 2017

This is part of a series of discussions regarding Deploying to a Digital Ocean Droplet. For more details, please see Overview of website

Install Mongo Ubuntu

How to Install MongoDB on Ubuntu 16.04

How to Install and Secure MongoDB on Ubuntu 16.04

sudo apt-get update

Adding the MongoDB Repository

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

Issue the following command to create a list file for MongoDB.

echo "deb xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

After adding the repository details, we need to update the packages list.

sudo apt-get update

Installing and Verifying MongoDB

Now we can install the MongoDB package itself.

sudo apt-get install -y mongodb-org

We’ll create a unit file to manage the MongoDB service.

sudo vi /etc/systemd/system/mongodb.service
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

Check that the service has started properly.

sudo systemctl status mongodb

Enable automatically starting MongoDB when the system starts.

sudo systemctl enable mongodb