In this article, we will learn how to install mongo db in windows. If you want to learn what ss Mongo db and difference between SQL and Mongo DB, then please read my previous blog from here.
Now, we will procced to install mongo db in our windows. Please follow below steps.
Please download community version (in .msi) from mongo db downloads.
Navigate to the folder where above file was downloaded. Right click on the file and click on Install.
Click next and choose complete setup type here.
Copy Data Directory path and click on Next. Then click on Install.
That’s it! You have successfully installed mongo db. To verify that navigate to the path that we have copied on above step. i.e C:\Program Files\MongoDB\Server\4.4\bin
Open Command Prompt and run this command.
"C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe" --version
You can check that we have installed mongo v4.
To query in mongo, Please run this command.
"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe" --version
It will open a mongo shell. To retrieve a name of the database, use this command.
> show dbs
It is a headache that to open a mongo shell, every time we have to execute this log command. To solve this problem we can set Environment Variable.
Open Edit the system environment variable from control panel.
Click on Environment Variable button.
Now, select path from the upmost section and click on Edit.
Add a new path that we have copied in step 4 and click ok.
Now open a command prompt again and just write mongo and hit enter.
Now you are able to open a mongo shell using just a mongo command.
Hope you guys found something useful. Please give your valuable feedback/comments/questions about this article. Please let me know how you like and understand this article and how I could improve it.