Navigation

Install MongoDB Enterprise Edition on Windows

Use this tutorial to install MongoDB Enterprise Edition 4.0 on Windows hosts.

Note

To install a different version of MongoDB, please refer to that version’s documentation. To install the previous version, see the tutorial for version 3.6.

System Requirements

Hardware Requirements

MongoDB Enterprise Edition requires an x86 64-bit architecture. See Supported Platforms for more information.

Software Requirements

Install on Windows 7 / Server 2008 R2 or Later

MongoDB Enterprise Edition requires Microsoft Windows Server 2008 R2 or later or Microsoft Windows 7 or later for the x86 64-bit architecture.

To find which version, service pack, and build of Windows is running on your host, as well as the processor type of that host, enter the following command in either the Command Prompt or Powershell:

systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.17134 N/A Build 17134
System Type:               x64-based PC
Show All File Name Extensions

Make certain that you set Windows Explorer/File Explorer to show file name extensions for all file types. This can prevent issues where the file type displayed to the user differs from the actual file type.

Example

If Windows Explorer/File Explorer has known file extensions hidden, what may appear to be mongod.cfg is actually mongod.cfg.txt.

Install all Windows Updates

Before installing MongoDB, update your Windows host with the latest system updates. At minimum, ensure the following Windows updates are installed on the host:

  • Windows 2012 Server and Windows 10 need KB2999226 to provide Universal C Runtime support for Windows.
  • Windows Server 2008 R2 and Windows 7 need KB2731284 to resolve an issue with memory mapped files on Windows.

The Windows installer (.msi) file includes all other software dependencies and automatically upgrades any previous version of MongoDB in the same release series (3.4.1 to 3.4.2) that was installed using an .msi file. Upgrading a full release series (3.4 to 3.6) requires a new installation.

Security

Starting with MongoDB 3.6, MongoDB binaries, mongod and mongos, bind to localhost by default. From MongoDB versions 2.6 to 3.4, only the binaries from the official MongoDB RPM (Red Hat, CentOS, Fedora Linux, and derivatives) and DEB (Debian, Ubuntu, and derivatives) packages would bind to localhost by default. To learn more about this change, see Localhost Binding Compatibility Changes.

Warning

Do not expose mongod.exe to a public network without configuring authentication. MongoDB is designed to be run in trusted environments.

Considerations

Use Command Interpreter, not Powershell

Every time this tutorial refers to the command line, you should use the Windows command interpreter (cmd.exe) with Administrative privileges. Not all commands work in Powershell.

To start cmd.exe with Administrative privileges:

  1. Open the Start menu.

    • Press the windows icon key.
    • Click on the Start windows icon icon at the left end of the taskbar.
  2. Type cmd.exe in the search box.

  3. Press Ctrl + Shift + Enter.

    This starts the Command Prompt as the Administrator user.

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\4.0\bin to your System PATH and then omit the full path to the MongoDB binaries.

Remember the directory where you installed MongoDB

This tutorial uses the default MongoDB Enterprise Edition location of C:\Program Files\MongoDB\Server\4.0\.

If you have installed in an alternative directory, you must adjust the paths as appropriate.

Install MongoDB Enterprise Edition

You can install using the Windows Installer wizard or from the command line.

You may install MongoDB Enterprise Edition using the Windows Installer and following its wizard.

Starting in MongoDB 4.0, you can set up MongoDB as a service during the install.

1

Download MongoDB Enterprise Edition.

  1. Open a web browser and visit the MongoDB Download Center.
  2. The Download Center should display the Release. From the Platforms menu, click Windows x64.
  3. Click Download.
  4. When the Install MongoDB Enterprise modal appears, click the msi link.
2

Open Windows Explorer/File Explorer.

3
4

Double-click the .msi file.

5

Follow the MongoDB Enterprise Edition installation wizard.

The wizard steps you through the installation of MongoDB and MongoDB Compass.

You can choose either the Complete or Custom setup type. 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.

Starting in MongoDB 4.0, you can, by default, configure and start MongoDB as a service during the install, and the MongoDB service is started upon successful installation.

Image of the MongoDB Installer wizard. Optional Windows Service Configuration.
  • If you choose not to configure MongoDB as a service, uncheck the Install MongoD as a Service.
  • If you choose to configure MongoDB as a service, you can:
    • Specify to run the service as one of the following users:
      • Network Service user; i.e. a Windows user account that is built-in to Windows
      • Local or domain user:
        • For an existing local user account, specify a period (i.e. .) for the Account Domain and the Account Name and the Account Password for the user.
        • For an existing domain user, specify the Account Domain, the Account Name and the Account Password for that user.
    • Specify the Service Name. If you already have a service with the specified name, you must choose another name.
    • Specify the Data directory, which corresponds to the --dbpath. If the directory does not exist, the installer will create the directory and sets the directory access to the service user.
    • Specify the Log directory, which corresponds to the --logpath. If the directory does not exist, the installer will create the directory and sets the directory access to the service user.

You may install MongoDB Enterprise Edition unattended on Windows from the command line using msiexec.exe.

1

Download MongoDB Enterprise Edition.

  1. Open a web browser and visit the MongoDB Download Center.
  2. The Download Center should display the Release. From the Platforms menu, click Windows x64.
  3. Click Download.
  4. When the Install MongoDB Enterprise modal appears, click the msi link.
2

Run the Windows Installer from the Windows Command Interpreter.

To install all MongoDB binaries, including MongoDB Compass, to the default installation directory, go to the directory containing the .msi installation binary and invoke:

msiexec.exe /l*v mdbinstall.log  /qb /i mongodb-win32-x86_64-enterprise-windows-64-4.0.0-signed.msi

To specify a different installation location for the executables, add the INSTALLLOCATION value.

msiexec.exe /l*v mdbinstall.log  /qb /i mongodb-win32-x86_64-enterprise-windows-64-4.0.0-signed.msi ^
            INSTALLLOCATION="C:\MongoDB\Server\4.0\"

By default, this method installs all MongoDB binaries. To install specific MongoDB component sets, you can specify them in the ADDLOCAL argument using a comma-separated list including one or more of the following component sets:

Component Set Binaries
Server mongod.exe
ServerService Set up mongod.exe as a service. Use in conjunction with Server to install and set up MongoDB as a service.
Router mongos.exe
Client mongo.exe
MonitoringTools mongostat.exe, mongotop.exe
ImportExportTools mongodump.exe, mongorestore.exe, mongoexport.exe, mongoimport.exe
MiscellaneousTools bsondump.exe, mongofiles.exe

To install just the MongoDB server and set up as a service and the mongo.exe shell, invoke:

msiexec.exe /l*v mdbinstall.log  /qb /i mongodb-win32-x86_64-enterprise-windows-64-4.0.0-signed.msi ^
            ADDLOCAL="Server,ServerService,Client"

To install only the MongoDB utilities, invoke:

msiexec.exe /l*v mdbinstall.log  /qb /i mongodb-win32-x86_64-enterprise-windows-64-4.0.0-signed.msi ^
            ADDLOCAL="MonitoringTools,ImportExportTools,MiscellaneousTools"

If you do not wish to install MongoDB Compass at this time, include the SHOULD_INSTALL_COMPASS="0" argument.

msiexec.exe /l*v mdbinstall.log  /qb /i mongodb-win32-x86_64-enterprise-windows-64-4.0.0-signed.msi ^
            SHOULD_INSTALL_COMPASS="0"

Start MongoDB Enterprise Edition from the Command Interpreter

1

Create database and log directories.

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB.

Invoke the following command in the Command Interpreter to create these directories:

md "\data\db" "\data\log"

Note

The quotations marks matter when creating more than one directory path at the same time.

2

Start your MongoDB database.

To start MongoDB, invoke mongod.exe.

Example

From the Command Interpreter:

"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe" --dbpath="c:\data\db"

The --dbpath option points to your database directory.

Note

If your path includes spaces, enclose the entire path in double quotes:

"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe" --dbpath "d:\test\mongo db data"

If the MongoDB database server is running correctly, the Command Interpreter displays:

[initandlisten] waiting for connections

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\4.0\bin\mongod.exe from communicating on networks. To remedy this issue:

  1. Click Private Networks, such as my home or work network.
  2. Click Allow access.

To learn more about security and MongoDB, see the Security Documentation.

3

Connect to MongoDB.

To connect to MongoDB through the mongo.exe shell, open another Command Interpreter.

"C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe"

Start MongoDB Enterprise Edition as a Windows Service

Starting in version 4.0, you can install and configure MongoDB as a Windows Service during the install, and the MongoDB service is started upon successful installation.

To start/restart the service, you can use the Services Manager.

You can also manage the service from the command line. To start the MongoDB service from the command line, invoke the following command:

1

Start the MongoDB service.

Close all other command prompts, then invoke the following command:

net start MongoDB
2

Verify that MongoDB has started successfully.

Check your MongoDB log file for the following line:

[initandlisten] waiting for connections on port 27017

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.

3

Connect to the MongoDB server.

To connect to MongoDB through the mongo.exe shell, open another Command Interpreter.

"C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe"

Stop MongoDB Enterprise Edition as a Windows Service

To stop/pause the MongoDB service, you can use the Services Manager.

You can also manage the service from the command line. To stop the MongoDB service from the command line, invoke the following command:

net stop MongoDB

Remove MongoDB Enterprise Edition as a Windows Service

To remove the MongoDB service, first stop the service and then run the following command:

sc.exe delete MongoDB