How to Install MongoDB on Windows

How to Install MongoDB on Windows Operating System

In this article, I am going to discuss How to Install MongoDB on Windows and macOS Operating Systems.

How to install MongoDB on Windows

MongoDB is the most popular unstructured database management system. It is used to store a large amount of data. It is a document-oriented database system. It is also a NoSQL (non-SQL) database. Now, let us see, how to install MongoDB on Windows. Here we divide the installation of MongoDB into three parts:

  1. Installing MongoDB Server
  2. Installing Mongo Shell
  3. Connection MongoDB Server and Mongo shell
Installing MongoDB Server

To install MongoDB Server on Windows, use the following steps-

Step 1- Open the browser and go to the MongoDB Download Centre to download the MongoDB Community Server.

link: https://www.mongodb.com/try/download/community

Installing MongoDB Server

Here you can select the following options to download the latest version of MongoDB Server:
Version – 6.0.1(current)
Platform – Windows
Package – msi

How to install MongoDB on Windows

After selecting these options click on the Download button and the downloading will start.

Step 2 – After completing the download open MSI file and click on the next button to start the setup.

How to install MongoDB on Windows

Step 3 – Accept the End user license agreement and click next.

How to install MongoDB on Windows Operating System

Step 4 – Click on the complete option to install all the features. If you want selected features then select the custom option.

How to install MongoDB on Windows Operating System

Step 5 – Choose Run service as Network Service user and copy the path of the data directory. And click on the next button.

How to install MongoDB on Windows Operating System

Step 6 – To start the installation process click on the install button and Installation will begin.

How to install MongoDB on Windows Operating System

Step 7 – Click on the finish button to complete the process.

How to install MongoDB on Windows and macOS Operating System

Step 8 – Go to the location where the MongoDB server is installed (mentioned in step 5) and copy the bin path.

Step 9 – Create an environment variable: Open system properties << Environment Variable << System variable << path << Edit Environment variable. Now paste the copied link and click ok.

How to install MongoDB on Windows and macOS Operating System

Step 10 – Now to run the MongoDB server (that is mongod), open the command prompt and run the following command:

mongod

Here, our command returns back which means we get an error and the error is

How to install MongoDB on Windows and macOS Operating System

It means it does not create a data directory to store data.

Step 11 – Open C dive and create a folder with named “data” and inside this folder create another folder with the name “db”.

Step 12 – Now again run the MongoDB server

How to install MongoDB on Windows and macOS Operating System

Installing MongoDB Shell on Windows Operating System

To install MongoDB Shell on Windows, use the following steps-

Step 1– Open the browser and go to the MongoDB Download Centre and then go to tools to download the MongoDB Shell.

link: https://www.mongodb.com/try/download/community

Installing MongoDB Shell on Windows Operating System

Here you can select the following options to download the latest version of MongoDB Shell:
Version – 1.6.0
Platform – Windows
Package – zip

Installing MongoDB Shell on Windows Operating System

After selecting these options click on the Download button and the downloading will start.

Step 2 – After downloading extract the downloaded file where ever you want.

Step 3 – Set the environment variable.

Installing MongoDB Shell on Windows Operating System

Installing MongoDB Shell on Windows Operating System

Step 4 – Open mongosh.exe and press enter to run mongoshell:

Connecting MongoDB Server and Mongo shell

Follow the following steps to connect MongoDB Server and Mongo shell:

Step 1 – Open the command prompt and run the mongod server using the following command:

Mongod

Connecting MongoDB Server and Mongo shell

Do not close this window. If you close this window the connection will lose.

Step 2 – Run mongosh.exe and press enter.

This is how the MongoDB shell will connect with the MongoDB server.

Connecting MongoDB Server and Mongo shell

In the next article, I am going to discuss How to Install MongoDB on macOS. Here, in this article, I try to explain How to Install MongoDB on Windows Operating System. I hope you enjoy this How to Install MongoDB on Windows Operating System article.

Leave a Reply

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