How to install mongodb on Ubuntu 18.04

MongoDB is a popular NoSQL database. It is ideal for use in scenarios where you do not need transaction capabilities across rows. Such applications include social media applications, UI dashboards, reporting, etc. Ubuntu 18.04 is the latest Linux distribution from Canonical at the time of writing this post. We use this because it is a popular choice for dev/test scenarios.

For dev/test scenarios, you want to ideally start with free software to limit cost, therefore, this post describes how to install mongodb community edition. We also use Ubuntu 18.04 Linux operating system that is free to download and use. We also show how to install in a very easy manner without the complexities of clustering, replication, security, etc because for dev/test applications on a controlled machine these are not critical. The mongodb package used is the one that is available in the Ubuntu 18.04 package repo.

Note that this post does not show you how to install for production use. Every production scenario has scale, availability and security issues that must be considered at deployment. It also assumes that you are comfortable with operating as an admin in the Linux operating system environment. Contact us if you would like us to host MongoDB and support it for you.


Most importantly, first make sure that you have met the following pre-requisites.

  • Install Ubuntu 18.04 on a physical or virtual machine. It is advisable to have at least two CPUs (or vCPUs if you are on virtual machine), 4GB RAM (more the merrier since MongoDB likes to use available memory for better performance).
  • Login as a sudo non-root user

Update Ubuntu 18.04 package list:

First, we must make sure we are up to date on packages because we do not want to hold on to any potential security vulnerabilities before we install MongoDB.

 sudo apt update

Install MongoDB Community Edition package:

We are going to install the community edition that is free to use. If you are in doubt about the commercial implications, please refer to the necessary licensing documents at MongoDB and Ubuntu 18.04 websites. Click here to contact us for hosted MongoDB with support.

sudo apt install -y mongodb 

Verify MongoDB is installed and operational correctly:

sudo systemctl status mongodb 

You will see the mongodb service output on the console.

Leave a Comment

Your email address will not be published. Required fields are marked *