How to Start MongoDB From Windows

Tahseen Tauseef Feb 15, 2024
  1. MongoDB Platform Support
  2. Download MongoDB Installation
  3. Running the MongoDB Installer
  4. Choose Setup Type
  5. Service Configuration
  6. Install MongoDB or mongosh in Windows
  7. Use Windows Services Console To Start and Stop MongoDB Service
  8. Disable the Windows Service for MongoDB Community Edition
How to Start MongoDB From Windows

Use this MongoDB tutorial article to install and start MongoDB 5.0 Community Edition on Windows using the default installation wizard.

The default MSI installation procedure is used in this article to install MongoDB on Windows. However, system administrators can use the msiexec.exe utility to deploy MongoDB in an unattended manner utilizing automation.

MongoDB Server does not include the MongoDB Shell (mongosh). To download and install mongosh, you must first follow the installation instructions for mongosh.

MongoDB Platform Support

MongoDB 5.0 Community Edition only supports the following 64-bit versions of Windows on x86_64 architecture:

  1. Windows Server 2019
  2. Windows 10 / Windows Server 2016

MongoDB supports only the 64-bit versions of these systems. On Windows hosts running Hyper-V, Oracle provides experimental support for VirtualBox.

Microsoft, on the other hand, does not support VirtualBox on Hyper-V. If you wish to use VirtualBox to install MongoDB on Windows, disable Hyper-V.

Download MongoDB Installation

Follow these instructions to use the MongoDB Installer wizard to install MongoDB Community Edition. The MongoDB binaries and the default configuration file install directory>binmongod.cfg are installed during the installation process.

➤ MongoDB Download Center

  1. In the Version dropdown, select the version of MongoDB to download.
  2. In the Platform dropdown, select Windows.
  3. In the Package dropdown, select msi.
  4. Click Download.

install mongodb in windows

Running the MongoDB Installer

You can run it from Windows Explorer/File Explorer.

  1. Go to the specific directory where you have downloaded the MongoDB installer (.msi file). By default, this is your Downloads directory.
  2. Double-click the .msi file in the directory.

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

Choose Setup Type

The Complete setup or Custom setup options are available. MongoDB and the MongoDB tools are installed to the default location with the Complete setup option.

You may define which executables are installed and where they are installed using the Custom setup option.

Service Configuration

Starting with MongoDB 4.0, you may either install the binaries or set up MongoDB as a Windows service during the installation. MongoDB Service MongoDB is a database management system.

MongoDB is installed and configured as a Windows service using the steps below. Starting with MongoDB 4.0, you may set up and start MongoDB as a Windows service during the installation process, and the MongoDB service is launched when the installation is complete.

MongoDB Service Customization

  1. Select Install MongoDB as a Service.
  2. Select either:

As the Network Service user, run the service (Default). This is a Windows user account that comes with the operating system.

or

As a local or domain user, start the service.

  1. Set the Account Domain to a period and the user’s Account Name and Account Password for an existing local user account.
  2. For an existing domain user, specify the Account Domain, the Account Name, and the Account Password for that user.
  3. Details of Directories in MongoDB are:
  • Service Name: Enter the name of the service. MongoDB is the default name. You must specify a new name if you already have a service with the supplied name.
  • Data Directory: Specify the data directory using the -dbpath option. If the directory does not exist, the installer will build it and provide the service user directory access.
  • Log Directory: This option specifies the log directory corresponding to the -logpath option. If the directory doesn’t exist, the installer will build it and provide the service user directory access.

Install MongoDB or mongosh in Windows

Check the box with the Install MongoDB Compass Label to install MongoDB Compass. When ready, click the "Next" button.

Installing MongoDB Compass is optional.

Install MongoDB Compass

The .msi installer does not include mongosh. You can install it from the Mongosh Installer.

install mongosh in windows

After a successful installation, the MongoDB service starts. Configure the MongoDB instance using the install directory>binmongod.cfg configuration file.

You must manually start the MongoDB instance if you merely installed the executables and did not install MongoDB as a Windows service.

MongoDB may now be installed and configured as a Windows Service starting with version 4.0. After a successful installation, the MongoDB service starts.

Configure the MongoDB instance using the install directory>binmongod.cfg configuration file. During installation, add the path to your mongosh.exe binary to your PATH environment variable.

Then, to connect to MongoDB, open a new Command Interpreter and type mongosh.exe.

Use Windows Services Console To Start and Stop MongoDB Service

Use the Services console to start the MongoDB service.

  1. From the Services console, locate the MongoDB service.
  2. Right-click on the MongoDB service and click Start.

Use the Services console to stop the MongoDB service.

  1. Locate the MongoDB service in the Services console.
  2. Stop the MongoDB service by right-clicking on it (or Pause).

Disable the Windows Service for MongoDB Community Edition

To uninstall the MongoDB service, stop using the Services console. Then, as an Administrator, open a Windows command prompt/interpreter (cmd.exe) and run the following command.

Command:

sc.exe delete MongoDB

uninstall mongodb in command prompt

In this article, the download and installation of MongoDB are covered, and steps to install MongoDB as a service are pointed out.

Related Article - MongoDB Connection