MongoDB installation on Ubuntu

Need to know the process of installing MongoDB on Ubuntu 20.04? Here is a complete guide on how to do it.

As part of our Server Management Services here at Ibmi Media, we regularly help our customers Install Software on their Debian and Ubuntu Server.

In this context, we shall look into how to install MongoDB on Ubuntu.

Learn More about MongoDB?

MongoDB is a Robust open-source document database and leading NoSQL database. It is written in C++ and its database helps businesses transform their industries by harnessing the power of data.

MongoDB supports Solaris, Linux, Windows as well as Mac OS X Operating System.

How to perform MongoDB installation on Ubuntu?

To install MongoDB on Ubuntu, follow the steps below;

i. MongoDB Installation on Ubuntu

To begin, start by updating the system packages with the command below;

sudo apt update

Next, install MongoDB with the following command;

sudo apt install mongodb -y

This will install different packages and dependencies with MongoDB management tools for MongoDB Server.

ii. MongoDB Server verification and Checking MongoDB Database

To confirm if MongoDB Server and database is running, run the following command;

sudo systemctl status mongodb

If active, you will notice that the output will display as service active.

To test if the database is functioning correctly, run the command below;

mongo --eval 'db.runCommand({ connectionStatus: 1 })'

iii. MongoDB Service Management

Managing MongoDB service is easy. You can check if the service is active with the command below;

sudo systemctl status mongodb

You can stop the service with the command;

sudo systemctl stop mongodb

To start MongoDB server again, run the command below;

sudo systemctl start mongodb

To restart MongoDB Server, run the command below;

sudo systemctl restart mongodb

By default, MongoDB Service starts automatically after installation. Therefore, if you wish to disable automatic startup, you need to run the command below;

sudo systemctl disable mongodb

To re-enable the service to startup automatically again, run the command below;

sudo systemctl enable mongodb

Need support in Managing your Debian, Ubuntu and CentOS Server? We are available to help you today.


This article will guide you on how to install MongoDB on Ubuntu.