Back to: MongoDB Tutorials
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:
- Installing MongoDB Server
- Installing Mongo Shell
- 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
Here you can select the following options to download the latest version of MongoDB Server:
Version – 6.0.1(current)
Platform – Windows
Package – msi
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.
Step 3 – Accept the End user license agreement and click next.
Step 4 – Click on the complete option to install all the features. If you want selected features then select the custom option.
Step 5 – Choose Run service as Network Service user and copy the path of the data directory. And click on the next button.
Step 6 – To start the installation process click on the install button and Installation will begin.
Step 7 – Click on the finish button to complete the process.
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.
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
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
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
Here you can select the following options to download the latest version of MongoDB Shell:
Version – 1.6.0
Platform – Windows
Package – zip
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.
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
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.
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.