Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install MongoDB on Windows

Install MongoDB Community Server with the MSI package, add it to the PATH and start the server.

Windows Hosting2 min read10 steps10 screenshots

Step 1: Download MongoDB

Open the MongoDB website, go to the Community Server download page, choose Windows and the msi package, and download it.

Downloading MongoDB

Step 2: Run the MSI package

  1. Open the downloaded file and click Next.
    The MongoDB setup
  2. Accept the license agreement.
    The license agreement
  3. Choose Complete (or Custom if you want another folder).
    Choosing the setup type
  4. Choose to run MongoDB as a Windows service. This starts it automatically. Keep the default data and log folders.
    Custom service settings
  5. Keep MongoDB Compass (the graphical tool) ticked, if you want it. Click Install.
    Installing MongoDB
  6. Click Finish.
    The installation is complete

Run MongoDB by hand

If you did not install it as a service, make the data folder first:

mkdir C:\data\db

Add the MongoDB bin folder to the PATH. It is usually C:\Program Files\MongoDB\Server\7.0\bin:

The MongoDB settings
Setting the environment variable

Open a new Command Prompt and start the server:

mongod
The MongoDB server running

In the log you can see that:

  1. MongoDB started and uses the data folder C:/data/db/.
  2. TLS 1.0 is turned off by default.
  3. Multi-threading is on.
  4. MongoDB listens on 127.0.0.1 at port 27017.

Connect to MongoDB

Open another Command Prompt and use the MongoDB Shell (mongosh; install it from the MongoDB site if it is not there):

mongosh

Try:

show dbs
use test
db.items.insertOne({ name: "first" })

Or use MongoDB Compass and connect to mongodb://localhost:27017.

Quick recap

  • Download the MSI and run it as a service.
  • Add the bin folder to the PATH.
  • Connect with mongosh on port 27017.