Skip to main content

Command Palette

Search for a command to run...

How to Install MongoDB with mongosh on Windows (Manually)

Updated
2 min read
How to Install MongoDB with mongosh on Windows (Manually)

Hello Devs! Here's a clean step-by-step guide you can use to install and run MongoDB with mongosh on Windows:

Step 1: Download MongoDB Server


Step 2: Install MongoDB Server

  • Run the .msi file.

  • During installation:

    • Select Complete setup.

    • ✔️ Enable “Install MongoDB as a Service” (recommended).

    • ✔️ Check “Install MongoDB Compass” if you need GUI (for beginners).


Step 3: Create Data Directory

MongoDB stores database files in C:\data\db by default.

  • Open PowerShell and run:

      mkdir C:\data\db
    

Step 4: Start MongoDB Server

  • Open a new terminal and run:

      mongod
    
  • You’ll see logs like Waiting for connections at 127.0.0.1:27017


Step 5: Download mongosh (Mongo Shell)

MongoDB no longer includes mongosh by default.


Step 6: Move mongosh to Program Files

  • Create a folder:

      C:\Program Files\MongoDB\mongosh
    
  • Move all extracted files (from mongosh-2.5.3-win32-x64) into this folder.


Step 7: Add MongoDB to System PATH

So you can use mongod and mongosh from anywhere.

  1. Press Win + S, search for Environment Variables, and open it.

  2. Under System Variables, find Path → click Edit.

  3. Click New, and add these:

     C:\Program Files\MongoDB\Server\8.0\bin
     C:\Program Files\MongoDB\mongosh\bin
    
  4. Click OK → OK → OK to close all dialogs.


Step 8: Verify Installation

Open a new PowerShell or CMD window and run:

mongod --version
mongosh --version

Both should return version info.


Step 9: Connect to MongoDB

  • Run:

      mongosh
    
  • You’ll connect to mongodb://127.0.0.1:27017 and enter the Mongo shell prompt:

      test>
    

You're now ready to use MongoDB!

So! this was a step-by-step guide to installing and running MongoDB with mongosh on Windows. It involves downloading the MongoDB server and mongosh, installing them, setting up a data directory, and adding executables to the system PATH. Finally, you verify the installation and connect to MongoDB using mongosh.


31 views