Skip to main content

Install MongoDB Windows

· One min read
  1. Download the .msi installer: mongodb.com: Community Edition

  2. Start the wizard by double-clicking the .msi file

  3. In wizard:
    a. Change location to F:\Program Files\MongoDB\Server\5.0\bin
    b. Uncheck the Install MongoDB as a Service
    c. Uncheck the Install MongoDB Compass
    d. Click Install

  4. Add C:\Program Files\MongoDB\Server\5.0\bin to your PATH environment variable

Install mongosh

  1. Download and run the MongoDB Shell .msi installer: mongodb.com: Shell
  2. Accept location: F:\Users\parsh\AppData\Local\Programs\mongosh
  3. Add the mongosh binary (F:\Users\parsh\AppData\Local\Programs\mongosh) to your PATH environment variable

Run MongoDB

  1. Run cmd as admin and create the data directory:

    cmd
    c:
    md "\data\db"
  2. Start MongoDB database:

    cmd
    "F:\Program Files\MongoDB\Server\5.0\bin\mongod.exe" --dbpath="c:\data\db"

    # or simply

    mongod --dbpath="c:\data\db"
  3. Connect to MongoDB:

    cmd
    mongosh

    After running this command, you should see information about your MongoDB shell, the local server connection, and some additional information printed to the terminal.

Source