Header Ads Widget

Responsive Advertisement

How to install mongodb and how it's work in Windows

History of MongoDB Installation & Usage on Windows

🔹 Pre-2015: Manual Zip Installation

  • MongoDB distributions for Windows were provided as .zip archives.
  • Users had to manually:
    • Unzip the folder (e.g., mongodb-win32-x86_64-3.x.x.zip)
    • Move it to a location like C:\mongodb
    • Create data directories manually like C:\data\db
    • Start MongoDB using mongod.exe via Command Prompt

 Services were not installed automatically — users had to run MongoDB manually each time.


🔹 2016–2017: Community Awareness and Blog Tutorials

  • Tutorials (like yours from February 15, 2016) became popular.
  • Blogs explained:
    • How to run multiple MongoDB instances on different ports
    • How to connect via the mongo client
    • How to insert JSON documents manually

This period was crucial for learning MongoDB at a grassroots level, especially for developers using Windows as a dev environment.


🔹 2018–2019: MSI Installer + Windows Services

  • MongoDB provided an MSI installer:
    • Made setup easier
    • Added MongoDB as a Windows Service (optional during install)
  • Users no longer had to manually run mongod.exe
  • Data directories and logs were auto-configured
  • MongoDB Compass was introduced for GUI access

🔹 2020–Present: Modern Tools + MongoDB Atlas

  • Installation now supports:
    • Chocolatey: choco install mongodb
    • Windows Subsystem for Linux (WSL): Developers can run MongoDB natively on Linux inside Windows.
  • Many users moved to MongoDB Atlas (cloud version), reducing the need for local installs.
  • Windows developers still use local MongoDB for development/testing via MSI or Docker.

How to Mongo DB installation and work out in Windows :

  1. Download MongoDB:
    Download mongodb-win32-x86_64-3.0.7.zip from the official MongoDB website, unzip it, and place the folder named mongodb (which contains the bin directory) in the C:\ drive.
  2. Create Database Directory:
    In C:\, create the directory C:\data\db for a single instance of MongoDB.
    For multiple database instances, create folders like C:\data\db1, C:\data\db2, and so on.
  3. Start MongoDB Server:
    Open Command Prompt as Administrator and run:
    cd C:\mongodb\bin
    mongod.exe --dbpath C:\data\db
    This starts MongoDB on the default port 27017.
  4. Start Multiple MongoDB Instances:
    To run multiple databases on different ports, use:
    mongod.exe --dbpath C:\data\db1 --port 27018
    mongod.exe --dbpath C:\data\db2 --port 27019
  5. Open MongoDB Client:
    Again in Command Prompt (Admin), navigate to:
    cd C:\mongodb\bin
    Run mongo to open the default client connected to port 27017.
  6. Connect to Other DB Instances:
    Use:
    mongo --port 27018
    mongo --port 27019

Inserting JSON Data into MongoDB:

  1. After opening the client, you can begin inserting data in JSON format.
  2. Create a collection (like a table) named Customer.

Insert sample JSON data:


Like: {
     "firstName": "John",
     "lastName": "Smith",
     "age": 25,
     "address":
     {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021"
     },
     "phoneNumber":
     [
         {
           "type": "home",
           "number": "212 555-1234"
         },
         {
           "type": "fax",
           "number": "646 555-4567"
         }
     ]
 }

 

Querying Data in MongoDB:

  1. To fetch a specific document:

db.Customer.find({"firstName": "John"}).pretty()

  1. To fetch all documents:

db.Customer.find().pretty()


If you found this guide useful, feel free to comment below or share it with your fellow developers!

  

replica of mongodb
replica of mongodb




install mongodb
install mongodb




 

For More DSA Related information, visit

Ø  Bench mark of compiler using Ackerman function

Ø  Find the Missing Number

Ø  To check if the rows of a matrix are circularly identical in Java

Ø  how to check loop in array

Ø  100 door puzzle programs

Ø  Frequency Weaving Logic & Spiral Printing of a Rectangle

Ø  Zig Zag Matrix print multiple way

Ø  Greedy Algorithm’s or knapsack algorithms

Ø  understanding recursive method for binary tree

Ø  Dynamic Programming: Max Square Sub-matrix of 1s in a Matrix

Ø  Previous and Next Date Palindrome

Ø  Karatsuba's Algorithm for multiplying two large numbers

Ø  Multiplication In different Way

Ø  Division by Different way

Ø  How to draw a Tree from array of integer

Ø  Position of robot after given movements

Ø  Alphanumeric Random Number generator

Ø  Solving Tiger-Goat-Boatman Puzzle: BFS & DFS River Crossing

Ø  Dijkstra Shortest Path for directed an undirected graph

Ø  Dollar amount into the minimum number of currency denominations in java

Ø  Learn about Dijkstra’s Algorithm in Java [Click here]

 

For More Java Related information, visit

Ø  Streams Lambdas Collectors and Functional Interfaces in Java 8

Ø  Java 8 support static method or default method or both in the interface

Ø  Inheritance Understand

Ø  Serialization understanding

Ø  Clone Under standing

Ø  Exception understanding

Ø  Garbage Collection Under Standing

Ø  How work Garbage Collection in Java

Ø  Under Standing Of Mutable and Immutable Class

Ø  enum understand

Ø  Mastering Java 8 features


Post a Comment

0 Comments