How to Install and Configure MongoDB on Ubuntu 20.04

Louis SanchezMay 11th 2021, 2:01

Use this tutorial to install and configure MongoDB, which is a not only SQL (NoSQL) document storage server.

You will need access to a root account or an account with sudo privileges. To get the latest version of MongoDB, we need to add the MongoDB source to Ubuntu installation sources:

Step 1 : First, import the MongoDB GPG public key

wget -qO - | sudo apt-key add -

Step 2 : Create a list file and add an install source to it

echo "deb [ arch=amd64,arm64 ] focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

Step 4 : Update the apt repository sources and install the MongoDB server

sudo apt-get update
sudo apt-get install -y mongodb-org

Step 5 : You can start the mongod process by issuing the following command:

sudo systemctl start mongod

Step 5 : After installation completes, check the status of the MongoDB server

sudo service mongod status

Step 6 : Now you can start using the MongoDB server. To access the Mongo shell, use the following command


After installation, the MongoDB service should start automatically. You can check logs at /var/log/mongodb/mongod.log.