In this blog post, I am going to share with you how you can install MongoDB on Windows machine. Well, there are hundreds of tutorials available online related to this topic. You must be thinking why I need to create another tutorial. Well, thats true there are lots of tutorials out there, but those are old and outdated.
Infact, I have checked many of them, but when I am not satisfied with those tutorials, then I planned to create my tutorial from scratch. In my tutorial, you will learn to Setup MongoDB on Windows from scratch, and this tutorial is created with the latest updates.
If you are a MacOS user and wanted to setup MongoDB on mac, then you can check out this tutorial: Easy Way to Install MongoDB on MacOS. This tutorial help you to setup MongoDB on Mac machine from starting.
Install MongoDB on Windows
In order to set up MongoDB on Windows machine, it needs to be manually downloaded from their official website. Visit the MongoDB official website, you will see below options:
- Version - OS - Package - Download Button
MongoDB Package Downloading Process.
- By default, you will have “MongoDB Community Server” selected if not then select it.
- In the Version dropdown there are multiple versions available, choose the appropriate version you are willing to download.
- In the OS dropdown menu choose “Windows 64-bit x64” option for setting up MongoDB on Windows system.
- Must choose MSI from the Package dropdown list.
- Click on the download button, and it will start downloading your MongoDB package.
When your MongoDB file is completely downloaded, then move to the directory where the MongoDB installer (.msi) is kept. Double click on the installer, it will ask for accepting the Licence agreement. Then click on the complete button, and your installation process will start.
Now here comes the critical part, in order to work with MongoDB on Windows machine, we should add the bin folder’s path in the environmental variables.
How to include MongoDB to Bin Folder Path?
Right click on This PC => Advanced system setting => Environment Variables => System variables (Double click on it).
When you reached to System variables double click on it and include this line of code. As you can see I am using 4.0.9 MongoDB version in the path you can use whichever version you’ll be using at the time of setting up MongoDB in Windows machine.
You can easily confirm which MongoDB version you are using by running the given below command in your terminal.
mongo --version MongoDB shell version v4.0.6 git version: caa42a1f75a56c7643d0b68d3880444375ec42e3 allocator: system modules: none build environment: distarch: x86_64 target_arch: x86_64
Create a folder to store MongoDB data, hit the following command.
Everything has been put on its place, and now it’s time to hit the command
mongod in terminal to run mongo daemon. This service runs listens about the connection and works in the background.
Mongo daemon is working correctly in the background, and your applications are ready to be served by MongoDB on Windows. I would suggest always use latest version softwares and libraries to get rid of the compatibility issue with client-side apps.