Verified and Tested 06/01/21


In this How-To, we will walk you through the basic install and configuration of MongoDB on your Ubuntu 20.04 Cloud Server.

MongoDB is database software that stores specified information in one single table document instead of creating separate table documents for an item. This makes it easier to work with and space-efficient.

Install Required Dependency

First, you will need to install some dependencies to your system. You can install all of them with the following command:

apt-get install dirmngr gnupg apt-transport-https ca-certificates software-properties-common -y

Once all the dependencies are installed, you can proceed to the next step.

Installing MongoDB on Ubuntu

By default, the latest version of MongoDB is not included in the Ubuntu default repository. So you will need to add the MongoDB repository to your system.

First, download and add the GPG key with the following command:

wget -qO - | apt-key add -

Next,add the MongoDB repository to APT with the following command:

add-apt-repository 'deb [arch=amd64] focal/mongodb-org/4.4 multiverse'

Once the repository has been added, install the MongoDB with the following command:

apt-get install mongodb-org -y

Once the installation has been completed, start the Mongo service and enable it to start at system reboot:

systemctl enable --now mongod

Test MongoDB Installation

After installing MongoDB, you can verify the MongoDB version with the following command:

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

You should get the following output:

MongoDB shell version v4.4.6
connecting to: mongodb://
Implicit session: session { "id" : UUID("e839ac21-1232-4863-87b3-2be8eeb2dde6") }
MongoDB server version: 4.4.6
	"authInfo" : {
		"authenticatedUsers" : [ ],
		"authenticatedUserRoles" : [ ]
	"ok" : 1

Next, connect to the Mongo Shell with the following command:


Once you are connected, run the following command to test the MongoDB

> { atlantic: 100 } )


WriteResult({ "nInserted" : 1 })
> db.test.find()


{ "_id" : ObjectId("60b5e3ebe40bb5bb2fa369ae"), "atlantic" : 100 }

Next, exit from the MongoDB with the following command:

> exit

Congratulations! You have just installed MongoDB on your Ubuntu 20.04 VPS. Thank you for following along in this How-To and check back with us for any new updates.