Install MongoDB Community Edition on Windows with the MSI installer, add mongosh, verify the service, enable access control and fix common setup errors.
To install MongoDB on Windows, download the Community Edition .msi from the MongoDB Download Center, run it with the Complete setup type and leave Install MongoD as a Service ticked. The server then starts automatically. Install the MongoDB Shell (mongosh) separately, open a new terminal and run:
mongosh
If you get a prompt ending in test>, the server is installed, running and reachable. The steps below go through each stage and the things that commonly go wrong.
Before you start
Supported Windows versions. Current MongoDB releases support 64-bit Windows 11 and Windows Server 2022 on x86-64. There is no 32-bit build. Older MongoDB releases supported older Windows versions; check the platform support table in the installation guide for the release you choose.
Not WSL. MongoDB does not support running the server under Windows Subsystem for Linux. Use the native Windows installer or Docker.
Administrator rights are needed to run the installer and manage the service.
Which version. Pick the newest release marked "current" in the Download Center unless your application needs a specific one. Paths below contain <version>, which stands for the release series you installed, such as 8.0.
Choose the Version, set Platform to Windows and Package to msi.
Click Download.
Step 2: Run the setup wizard
Double-click the .msi file and work through the wizard.
Licence agreement. Accept it. The Community server is licensed under the Server Side Public License.
Setup type. Choose Complete. It installs the server and the bundled tools to the default location. Custom lets you change the location or leave components out.
The 100 MB blocking-sort limit means your index doesn't provide the sort order. Build compound indexes with the ESR rule, order pipeline stages correctly, and know when allowDiskUse is fine.
Service configuration. Leave Install MongoD as a Service selected, with these settings:
Run service as Network Service user is the default and is fine for most machines.
Service Name defaults to MongoDB.
Data Directory and Log Directory are where the databases and the log file go. The installer creates them and gives the service account access. If drive C: is small, point the data directory at a larger disk now; moving it later is more work.
MongoDB Compass. The checkbox installs Compass, MongoDB's graphical client. It is optional.
Click Install, then Finish.
The binaries are installed to C:\Program Files\MongoDB\Server\<version>\bin, and the service starts as soon as installation completes.
If you untick the service option, only the binaries are installed and you start the server yourself; see "Running without the service" below.
Step 3: Install mongosh
The server installer does not include a shell. The old mongo.exe shell that earlier tutorials use no longer ships with MongoDB; its replacement, mongosh, is a separate download.
Choose the Windows 64-bit MSI package, download it and run the installer.
Open a new PowerShell or Command Prompt window, so it picks up the updated PATH, and check the version. If the command is not found, add the folder that contains mongosh.exe to your PATH.
mongosh --version
Step 4: Verify the installation
Check that the service is running:
Get-Service MongoDB
The Status column should say Running. Connect and run a round trip:
ping returns { ok: 1 }, db.version() prints the server version, and the insert followed by find proves the server can write to its data directory. The last line removes the test database again.
Starting and stopping the service
From an Administrator PowerShell or Command Prompt:
net stop MongoDB
net start MongoDB
You can also use the Services console (services.msc). The service is set to start automatically with Windows.
The configuration file
The service reads its settings from C:\Program Files\MongoDB\Server\<version>\bin\mongod.cfg. It is a YAML file that the installer fills in with the directories you chose:
To change a setting, edit the file as Administrator, then stop and start the service. Indent with spaces only; YAML does not accept tab characters, and a tab in this file prevents the service from starting.
bindIp: 127.0.0.1 means the server accepts connections only from the same computer. That is the safe default.
Adding the server tools to PATH (optional)
You do not need mongod.exe on your PATH when MongoDB runs as a service. If you want to run it or the other server binaries by name, add the bin folder:
Press Win, type "environment variables" and open Edit the system environment variables.
Click Environment Variables, select Path under System variables and click Edit.
Add C:\Program Files\MongoDB\Server\<version>\bin and confirm.
Open a new terminal and run mongod --version.
Turning on access control
A fresh installation does not ask for a user name or password. That is acceptable while the server only listens on localhost on a development machine. Before you allow other machines to connect, create an administrator and enable authorization.
Only after that should you add the machine's network address to bindIp and open port 27017 in Windows Defender Firewall for the specific clients that need it.
Running without the service
If you installed only the binaries, or want a throwaway server, start mongod.exe yourself. Without options it looks for the data directory \data\db on the current drive and exits if the folder is missing, so create it or name another one:
Leave that window open; the server runs in the foreground and Ctrl+C stops it cleanly. Windows may show a firewall prompt the first time. A server started this way uses none of the settings in mongod.cfg unless you add --config with the path to the file.
Unattended installation
For scripted deployments, run the same .msi with msiexec from an Administrator prompt, replacing the file name with the one you downloaded:
ADDLOCAL="ServerService" installs the server and registers the service. Compass is installed unless you pass SHOULD_INSTALL_COMPASS="0".
Docker instead of a native install
If you have Docker Desktop and only need MongoDB for development, a container avoids the installer altogether:
docker run --name mongodb -p 27017:27017 -v mongodata:/data/db -d mongodb/mongodb-community-server:latest
The named volume mongodata keeps the data when the container is removed. Connect from Windows with mongosh as before. MongoDB 5.0 and later images need a CPU with AVX support.
Troubleshooting
Symptom
Cause and fix
'mongo' is not recognized as an internal or external command
The legacy shell no longer exists. Install and use mongosh.
'mongosh' is not recognized ...
mongosh is not installed, the terminal was opened before installation, or its folder is not on PATH.
'mongod' is not recognized ...
The server bin folder is not on PATH. Add it, or use the full path.
Nothing is listening. Check Get-Service MongoDB and start the service. If it will not start, read the log file.
Service stops immediately after you edit mongod.cfg
Invalid YAML (often a tab or wrong indentation) or a path that does not exist. The log file shows the reason.
mongod.exe exits with Data directory C:\data\db\ not found
You started it by hand without --dbpath and the default folder is missing.
Address already in use for port 27017
The service is already running and you started a second mongod.exe. Stop one, or give the second another --port.
Other computers cannot connect
bindIp is still 127.0.0.1, or the firewall blocks the port. Enable access control before changing either.
Upgrading and uninstalling
Running the .msi for a newer patch release of the same series (for example 8.0.x to a later 8.0.y) upgrades in place. Moving to a new release series is a new installation and must follow the upgrade procedure in the release notes for that version; MongoDB does not support skipping major versions when upgrading existing data.
To uninstall, stop the service and remove the MongoDB entry under Settings → Apps → Installed apps. Back up or delete the data and log directories yourself if you no longer need them. If a service entry is left behind, remove it from an Administrator prompt with sc.exe delete MongoDB.
What the mongod server process does, how it differs from mongos and mongosh, the options and config file that control it, and how to start and stop it safely.