0
0
MongodbHow-ToBeginner · 3 min read

How to Install MongoDB on Windows: Step-by-Step Guide

To install MongoDB on Windows, download the installer from the official MongoDB website, run it, and follow the setup wizard to complete the installation. After installation, start the mongod service to run the database server.
📐

Syntax

The installation process involves downloading the MongoDB installer, running it, and configuring the service. Key steps include:

  • Download: Get the MSI installer from the official MongoDB website.
  • Run Installer: Launch the MSI file and follow the prompts.
  • Service Setup: Choose to install MongoDB as a Windows service.
  • Start Server: Use mongod command or start the service.
shell
msiexec /i mongodb-windows-x86_64-<version>.msi /quiet
💻

Example

This example shows how to start the MongoDB server after installation using the command prompt.

shell
net start MongoDB

REM To stop the service:
net stop MongoDB
Output
The MongoDB service was started successfully. The MongoDB service was stopped successfully.
⚠️

Common Pitfalls

Common mistakes when installing MongoDB on Windows include:

  • Not adding MongoDB's bin folder to the system PATH, which makes commands like mongod unavailable in the terminal.
  • Forgetting to start the MongoDB service after installation.
  • Installing an outdated version instead of the latest stable release.
  • Not running the command prompt as Administrator when starting or stopping services.
shell
REM Wrong: Trying to run mongod without PATH set
mongod

REM Right: Add MongoDB bin to PATH or use full path
"C:\Program Files\MongoDB\Server\
📊

Quick Reference

StepDescription
Download InstallerGet MSI from https://www.mongodb.com/try/download/community
Run InstallerFollow setup wizard, select 'Complete' installation
Configure ServiceChoose to run MongoDB as a Windows service
Add to PATHAdd MongoDB bin folder to system PATH environment variable
Start ServiceRun 'net start MongoDB' in Administrator command prompt
Verify InstallationRun 'mongosh' shell to connect to server

Key Takeaways

Download the official MongoDB MSI installer for Windows from the MongoDB website.
Run the installer and choose to install MongoDB as a Windows service for easy management.
Add MongoDB's bin directory to your system PATH to run commands from any terminal.
Start the MongoDB service using 'net start MongoDB' in an Administrator command prompt.
Verify the installation by running the 'mongosh' shell to connect to the database server.