How to setup MongoDB on Windows

Step 1: Download MongoDB

Download the latest production release of MongoDB from: MongoDB downloads page. I have downloaded MongoDB for Windows 64-bit the filename is: mongodb-win32-x86_64-2008plus-ssl-3.4.7-signed.msi

Step 2: Install MongoDB for Windows.

In Windows Explorer, locate the downloaded MongoDB .msi file, which typically is located in the default Downloads folder. Double-click the .msi file. A set of screens will appear to guide you through the installation process.

You may specify an installation directory if you choose the “Custom” installation option.

Step 3: Setup the MongoDB Environment

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder.
I have created \data\db in the following path: D:\Programs\MongoDB\Server\3.4\data\db

To start MongoDB on Windows, use this path while executing mongod.exe in the bin folder location. Here is the command that I use in command prompt:
D:\Programs\MongoDB\Server\3.4\bin>mongod.exe --dbpath D:\Programs\MongoDB\Server\3.4\data

Step 4: Connect to MongoDB

To connect to MongoDB, in command prompt, execute mongo.exe in the bin folder location. Here is the command that I use:
D:\Programs\MongoDB\Server\3.4\bin>mongo.exe
In my MongoDB, I have created a database named: softwaredevelopercentral and collection named: employees. Hence once I connect, here are a few useful queries that I use:
> show dbs
> use softwaredevelopercentral
> db.employees.find().pretty()



Comments

Popular Posts

Elasticsearch, Logstash, Kibana Tutorial: Load MySQL Data into Elasticsearch

Dropwizard MySQL Integration Tutorial

Send Email in Java