In this article, let us know the steps to download and install MongoDB on Windows. So, we can use it for future references.
Step 1 — Download the MongoDB MSI Installer Package
Head over to the MongoDB download center site and download the current version of MongoDB. Make sure you select MSI as the package you want to download.
Step 2 — Install MongoDB with the Installation Wizard
A. Make sure you are logged in as a user with Admin privileges. Then navigate to your downloads folder and double click on the .msi package you just downloaded. This will launch the installation wizard.
Step 3: Click Next to start installation.
Step 4: Accept the licence agreement then click Next.
Step 5: Select the Complete setup.
Step 6: Select “Run service as Network Service user” and make a note of the data directory, we’ll need this later.
Step 7: We won’t need Mongo Compass, so deselect it and click Next.
Step 8: Click Install to begin installation.
Step 9: Hit Finish to complete installation.
H. Now we go to the location where MongoDB installed in step 5 in your system and copy the bin path:
Step 10: Now, to create an environment variable open system properties << Environment Variable << System variable << path << Edit Environment variable and paste the copied link to your environment system and click Ok:
Step 11:After setting the environment variable, we will run the MongoDB server, i.e. mongod. So, open the command prompt and run the following command:
mongod
When you run this command you will get an error i.e. C:/data/db/ not found.
Step 12: Open C drive and create a folder named “data” inside this folder create another folder named “db”. After creating these folders. Again open the command prompt and run the following command:
mongod
Now, this time the MongoDB server(i.e., mongod) will run successfully.
Run mongo Shell
Step 13: Now we are going to connect our server (mongod) with the mongo shell. So, keep that mongod window and open a new command prompt window and write mongo. Now, our mongo shell will successfully connect to the mongod.
Important Point: Please do not close the mongod window if you close this window your server will stop working and it will not able to connect with the mongo shell.
Save this article for future references.
Thank you for reading, please clap, share and comment. it will encourage me to write more such articles. Do share your valuable suggestions, I appreciate your honest feedback!!!