- Install MongoDB >
- Install MongoDB Community Edition >
- Install MongoDB Community Edition on Windows
Install MongoDB Community Edition on Windows¶
On this page
Overview¶
Use this tutorial to install MongoDB 3.6 Community Edition on Windows using the default installation wizard.
MongoDB Version¶
This tutorial installs MongoDB 3.6 Community Edition. To install a different version of MongoDB Community, use the version drop-down menu in the upper-left corner of this page to select the documentation for that version.
Installation Method¶
This tutorial installs MongoDB on Windows using the default MSI
installation wizard. To install MongoDB using the msiexec.exe
command-line tool instead, see Install MongoDB using msiexec.exe. The
msiexec.exe
tool is useful for system administrators who wish to
deploy MongoDB in an unattended fashion using automation.
Considerations¶
Platform Support¶
MongoDB 3.6 Community Edition supports the following 64-bit versions of Windows on x86_64 architecture:
- Windows 10 / Windows Server 2016
- Windows 8.1 / Windows Server 2012 R2
- Windows 8 / Windows Server 2012
- Windows 7 / Windows Server 2008 R2
MongoDB only supports the 64-bit versions of these platforms.
See Supported Platforms for more information.
Production Notes¶
Before deploying MongoDB in a production environment, consider the Production Notes document which offers performance considerations and configuration recommendations for production MongoDB deployments.
Install MongoDB Community Edition¶
Prerequisites¶
Users on Windows versions previous to Windows 10 must install the following update before installing MongoDB:
➤ Update for Universal C Runtime for Windows
Users on Windows 10, Server 2016 and Server 2019 do not need this update.
Procedure¶
Follow these steps to install MongoDB Community Edition using the
MongoDB Installer wizard. The installation process installs both the
MongoDB binaries as well as the default configuration file <install
directory>\bin\mongod.cfg
.
Download MongoDB Community Edition.¶
- Open a web browser and visit the MongoDB Download Center.
- The Download Center should display MongoDB Community Server tab. If not, select Server, then click the MongoDB Community Server tab.
- In the Version dropdown, select the version that corresponds to MongoDB Server 3.6. The download center always displays the latest available point version. For older point releases, click All version binaries in the right hand navigation box.
- In the OS dropdown, verify that
Windows 64-bit X64
is selected. - In the Package drop down, verify that
MSI
is selected. - Click Download.
Open Windows Explorer.¶
Double-click the .msi
file.¶
Follow the MongoDB Community Edition installation wizard.¶
If you choose the Custom installation option, you may specify an installation directory. MongoDB has no other system dependencies. You can install and run MongoDB from any directory.
Run MongoDB Community Edition from the Command Interpreter¶
Open a Windows command prompt/interpreter (cmd.exe
) as an Administrator.
Important
You must open the command interpreter as an Administrator.
Create the database directory.¶
Create the data directory where MongoDB stores data.
MongoDB’s default data directory path is the absolute path
\data\db
on the drive from which you start MongoDB.
From the Command Interpreter, create the data directory:
Start your MongoDB database.¶
To start MongoDB, invoke mongod.exe
.
The --dbpath
option points to your
database directory.
If the MongoDB database server is running correctly, the Command Interpreter displays:
Important
Depending on the
Windows Defender Firewall
settings on your Windows host, Windows may display a
Security Alert dialog box about blocking
“some features” of C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe
from communicating on networks. To remedy this issue:
- Click Private Networks, such as my home or work network.
- Click Allow access.
To learn more about security and MongoDB, see the Security Documentation.
Connect to MongoDB.¶
To connect a
mongo.exe
shell to the MongoDB instance, open another
Command Interpreter with Administrative privileges and run:
For more information on connecting a mongo.exe
shell, such as to connect to a MongoDB instance running on a different
host and/or port, see The mongo Shell. For information on CRUD
(Create,Read,Update,Delete) operations, see MongoDB CRUD Operations.
To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.
Run MongoDB Community Edition as a Windows Service¶
Start MongoDB Community Edition as a Windows Service¶
You can set up the MongoDB server as a Windows Service that starts automatically at boot time.
Create the database and log directories.¶
If you have not created the data and log directories for your MongoDB server, you must create them before running MongoDB Community Edition as a Windows service.
From the Command Interpreter, create the following directories:
Create a MongoDB configuration file.¶
Create a MongoDB configuration file:
Note
MongoDB configuration files use the
YAML file format. Per the YAML 1.2
specification,
all indents must use spaces to maintain portability. To ensure no
parsing errors, enclose all values in double quotation marks
("
) and escape any backslash characters (\
).
Set the storage.dbPath
and systemLog.path
. Include additional
configuration options as
needed:
Create the MongoDB service.¶
Invoke the following command in the Command Interpreter to create the service:
Note
sc.exe
requires a space between “=
” and the
configuration values (i.e. binPath= `` ) as well as using
`` "\"
and \""
to escape a double-quoted string.
If successfully created, the following message is written to the log:
Start the MongoDB service.¶
Close all other command prompts, then invoke the following command:
Verify that MongoDB has started successfully.¶
Check your MongoDB log file for the following line:
You may see non-critical warnings in the process output. As long as you see this message in the MongoDB log, you can safely ignore these warnings during your initial evaluation of MongoDB.
Stop MongoDB Community Edition as a Windows Service¶
To stop/pause the MongoDB service, use the Services console:
- From the Services console, locate the MongoDB service.
- Right-click on the MongoDB service and click Stop (or Pause).
You can also stop the MongoDB service from the Windows command prompt/interpreter (cmd.exe
). Open a Windows command prompt/interpreter (cmd.exe
) as an Administrator, and
run the following command:
Remove MongoDB Community Edition as a Windows Service¶
To remove the MongoDB service, first use the Services console to stop
the service. Then open a Windows command prompt/interpreter (cmd.exe
) as an Administrator, and
run the following command:
Additional Considerations¶
Localhost Binding by Default¶
By default, MongoDB launches with bindIp
set to
127.0.0.1
, which binds to the localhost network interface. This
means that the mongod.exe
can only accept connections from
clients that are running on the same machine. Remote clients will not be
able to connect to the mongod.exe
, and the mongod.exe
will
not be able to initialize a replica set unless this value is set
to a valid network interface.
This value can be configured either:
Warning
Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.
For more information on configuring bindIp
, see
MongoDB Configuration Hardening.
Point Releases and .msi
¶
If you installed MongoDB with the Windows installer (.msi
), the
.msi
automatically upgrades within its release series (e.g. 3.6.1 to 3.6.2).
Upgrading a full release series (e.g. 3.6 to 4.0) requires a new installation.
Add MongoDB binaries to the System PATH¶
All command-line examples in this tutorial are provided as absolute paths to the MongoDB binaries. You can add C:\Program Files\MongoDB\Server\3.6\bin
to your System PATH
and then omit the full path to the MongoDB binaries.