How to download & Install mongodb on Windows ?

The tutorial provides the step by step process for installing MongoDB on windows 10.

  • Download MongoDB from community site: Click on the Download MongoDB link and get the on-premises installer from the community site (mongodb-win32-x86_64-2012plus-4.2.8-signed)
Download Mongodb
Download MongoDB

Start the installer: Click on the msi windows 64-bit installer ( mongodb-win32-x86_64-2012plus-4.2.8-signed ). Click Next and Accept the License Agreement Terms checkbox.

MongoDB Installer
MongoDB Installer

Select Components: Click on “complete” button to install all the required MongoDB components.

Select MongoDB components
Select MongoDB components

Service Configuration: Select option as “Run Service as a Network Service user” . Click Next.

MongoDB Service Configuration
MongoDB Service Configuration

Install MongoDB compass: Click Next to start the installation for MongoDB compass

MongoDB compass Installation
MongoDB Installation readiness

MongoDB Installation Progress: The below screen shows the MongoDB installation progress.

MongoDB Installation progress
MongoDB Installation progress

Click Finish when the installation is completed.

MongoDB compass is the non-commercial interactive GUI for managing the MongoDB Structure , querying the available data with the data representation.

  • Interactive editor for displaying document structure
  • Provides visual explain plans
  • Provides index management
  • Provides editing with validation of individual BSON types
  • Provides replica set connection to avoid fail over
  • Provides Query history

MongoDB compass provides the privacy setting to be enabled to provide various reports for MongoDB Data crash, MongoDB Data Statistics and MongoDB automatic updates.

MongoDB Compass Privacy Settings
MongoDB Compass Privacy Settings

Starting MongoDB in windows

As MongoDB generated documents , it requires the data folder to be specified to store its file. Create the data folder in C:/

C:\>md data
C:\md data\db

Now we need to provide this data folder location while running the MongoDB exe as given below

C:\Program Files\MongoDB\Server\4.2\bin
C:\Program Files\MongoDB\Server\4.2\bin>mongod.exe --dbpath "C:\data" 

Execute the below command to start the MongoDB shell:

C:\Program Files\MongoDB\Server\4.2\bin>mongo.exe

Install Python Driver for using MongoDB

  • Python should be installed on the system as the prerequisite. PIP should be preferred for installing pymongo ( driver for MongoDB)
  • Execute the below command to install Python driver for using MongoDB NoSQL Database
  • PyMongo supports CPython 2.7, 3.4+, PyPy, and PyPy3.5+.
 $ python -m pip install pymongo    (command for install pymongo driver) 
$ python -m pip install --upgrade pymongo   (command to upgrade pymongo driver) 

Install Ruby Driver for using MongoDB

  • Ruby should be installed on the system as the prerequisite
  • Execute the below command to install Ruby driver for using MongoDB NoSQL Database

Install Java Driver for using MongoDB

The MongodB provides the 2 maven artifacts for using MongoDB with the java driver.

mongodb-driver-legacy driver:It is the synchronous legacy driver

Entry point – com.mongodb.MongoClient

Central classes – com.mongodb.DB, com. mongodb.DBCollection, and com.mongodb.DBCursor

mongodb-driver-sync driver: It is the synchronous Java driver which provides the generic MongoCollection interface that complies with a new cross-driver CRUD operations.

Module Name – org.mongodb.driver.sync.client

The mongodb-driver-sync artifact is a valid OSGi bundle whose symbolic name is org.mongodb.driver-sync

Dependency: Add the below dependency in Java application for using MongoDB driver

 <dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver-sync</artifactId>
        <version>4.0.4</version>
    </dependency>
</dependencies>