How to install MongoDB

There are different ways to install MongoDB on the different operating systems but I am showing only for ubuntu and Window. There are two ways of installing MongoDB on Ubuntu systems.

MongoDB install in Ubuntu

1) Install MongoDB from apt repository

2) Install MongoDB from a downloaded.deb package

but I am representing through command base

Step 1:- Import MongoDB public GPG Key:

Before you can install any package from MongoDB apt repository, you need to download and import GPG key to your system.


wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -

Step 2:- Add MongoDB 4 APT Repository on Ubuntu 18.04 / Ubuntu 16.04

Ubuntu 18.04:


echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Ubuntu 16.04:


echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Step 3:- Install MongoDB 4 on Ubuntu 18.04 / Ubuntu 16.04


sudo apt update
sudo apt install -y mongodb-org

The service name is mongod now you can start the application by below command:


sudo systemctl enable --now mongod

Check Mongo status


sudo systemctl status mongod

Note:- If it is showing active (running) means MongoDB is running perfectly.

MongoDB install in Window

Step1:-Firstly click on the URL https://www.mongodb.com/try/download/community after that select the version and select the Platform as a Window and select the package as msi after that click on download button.

Step2:- Now, double click on the msi file which is installed after that click on the next button.

Step3:- Now, click the next button.

Step4:- Now, You can change the path, where you want to install otherwise it will be install on C drive and after that click the next button.

Step5:- Now, click the next button.

Step6:- Now, click the install button.

Step7:- Now, MongoDB is started to installing.

Step8:- Now, MongoDB is installing is going on.

Step9:- Now, MongoDB Compass is loading.

Step8:- Now, MongoDB is installed and click on the finish button.

How to install MongoDB – Interview Questions

Q 1: How can you install MongoDB?
Ans: MongoDB can be installed by downloading the installer from the official MongoDB website and following the installation steps for the specific operating system.
Q 2: What is MongoDB Compass?
Ans: MongoDB Compass is a graphical interface tool used to interact with MongoDB databases.
Q 3: How do you verify MongoDB installation?
Ans: You can verify installation by running mongod --version or starting the MongoDB service.
Q 4: What is mongod?
Ans: mongod is the MongoDB server process that manages data storage and database operations.
Q 5: What is mongosh?
Ans: mongosh is the MongoDB shell used to interact with MongoDB using commands.

Related How to install MongoDB Topics