How to Install MongoDB on Windows, Start, Uninstall

Filed Under: MongoDB

Today we will learn how to install MongoDB on Windows. Most of us use Windows for our personal use. That’s why I am writing this tutorial to help you install MongoDB on Windows. We will also learn how to start and uninstall MongoDB on Windows.

MongoDB for Windows

Starting from MongoDB version 2.2, MongoDB doesn’t support Windows XP. So if you are on Windows XP, either upgrade it or use the lower versions of MongoDB. This tutorial is intended to help you in installing MongoDB on Windows latest versions i.e Windows 7 and Windows 8, 8.1 etc.

Install MongoDB on Windows

Follow below steps to perform the installation of MongoDB into your windows system.

  1. Consider specific MongoDB build type which you need actually

    Three build types of MongoDB for Windows are available.

    1. MongoDB for Windows Server 2008 R2 series: This build type runs only on 2008R2, Windows 7 64-bit, Windows 8, and latest versions of Windows.
    2. MongoDB for Windows 64-bit: This build type of MongoDB runs on any 64-bit version of Windows latest than Windows XP, involve Windows Server 2008 R2 and Windows 7 64-bit.
    3. MongoDB for Windows 32-bit: MongoDB runs on any 32-bit version of Windows latest than Windows XP, 32-bit version of MongoDB are only designed for older system and use for testing and developing systems. Windows 32-bit versions of MongoDB support only database smaller than 2GB.

    If you want to know that which specific version of windows you are running at your system, then simply use following command on command prompt.

    Microsoft Windows [Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All rights reserved.
    C:\Users\Pankaj>wmic os get osarchitecture
  2. Download MongoDB for Windows

    MongoDB for Windows Downloads Options

    Download the latest version release from the MongoDB Download page. Make sure you download the latest version of MongoDB for your Windows. Note that 64-bit versions of MongoDB do not run with 32-bit Windows.

  3. MongoDB Installation Options

    In Windows Explorer, simply locate downloaded MongoDB msi file, then Double-click the msi file. A series of screens will guide you through the installation procedure. There are multiple options such as Typical, Custom and Complete installation. MongoDB default installation goes into Program Files, so if you want to change it then go for Custom installation.

  4. MongoDB installation folder move to another location (Optional)

    Sometimes we want to move the installation to another directory, we can use move command for this. This command needs to be run as administrator. For example, to move the folder to C:\MongoDB follow the steps shown in below images.

    Install MongoDB on Windows Command-Prompt-As-Administrator

    MongoDB install windows

    MongoDB does not depend at any other system because it is self contained. You can execute MongoDB from the folder of your choice and can install it in any folder (for, example D:\test\mongodb)

Running MongoDB Server

We need to create a directory where MongoDB server will store all it’s data. The MongoDB default data directory path is \data\db. Make this folder using the following commands from Command Prompt. Note that if the directory doesn’t exists, MongoDB will try to create it. But it’s good to create it before hand.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Pankaj>cd \

C:\>md \data\db


To start MongoDB server, we need to run mongod.exe. For example, from the Command Prompt;


This MongoDB starts the main databases process. The waiting for connection message in the console results determines that the mongod.exe process is complete.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Pankaj>cd \

MongoDB\bin\mongod.exe --help for help and startup options
2014-11-11T13:36:19.016+0530 [initandlisten] MongoDB starting : pid=5292 port=27
017 dbpath=\data\db\ 64-bit host=Meghna
2014-11-11T13:36:19.017+0530 [initandlisten] targetMinOS: Windows 7/Windows Serv
er 2008 R2
2014-11-11T13:36:19.017+0530 [initandlisten] db version v2.6.5
2014-11-11T13:36:19.017+0530 [initandlisten] git version: e99d4fcb4279c0279796f2
2014-11-11T13:36:19.017+0530 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
2014-11-11T13:36:19.017+0530 [initandlisten] allocator: system
2014-11-11T13:36:19.017+0530 [initandlisten] options: {}
2014-11-11T13:36:19.092+0530 [initandlisten] journal dir=\data\db\journal
2014-11-11T13:36:19.094+0530 [initandlisten] recover : no journal files present,
 no recovery needed
2014-11-11T13:36:19.186+0530 [initandlisten] allocating new ns file \data\db\loc
al.ns, filling with zeroes...
2014-11-11T13:36:20.002+0530 [FileAllocator] allocating new datafile \data\db\lo
cal.0, filling with zeroes...
2014-11-11T13:36:20.003+0530 [FileAllocator] creating directory \data\db\_tmp
2014-11-11T13:36:20.031+0530 [FileAllocator] done allocating datafile \data\db\l
ocal.0, size: 64MB,  took 0.018 secs
2014-11-11T13:36:20.035+0530 [initandlisten] build index on: local.startup_log p
roperties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2014-11-11T13:36:20.036+0530 [initandlisten]     added index to empty collection

2014-11-11T13:36:20.037+0530 [initandlisten] command local.$cmd command: create
{ create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0
 numYields:0  reslen:37 851ms
2014-11-11T13:36:20.038+0530 [initandlisten] waiting for connections on port 270

You can use a different path for data files using the –dbpath option to mongod.exe, for example:

C:\>C:\MongoDB\bin\mongod.exe --dbpath D:\test\mongodb\data

If your path contains white spaces, then you need to use double quotes as shown below.

C:\>C:\MongoDB\bin\mongod.exe --dbpath "D:\test\mongo db data"

The security level depends on your system configurations, Windows provide pop up a Security Alert dialog box about blocking few features of C:\Folder Name\MongoDB\bin\mongod.exe from communication on networks.

All the clients should choose Private Networks. For example, my home or work network and click Allow access. For more information on security and MongoDB, please look into the Security Documentation.

Connecting to MongoDB server through Command Prompt

We can connect to MongoDB server through mongo.exe client application, just open another command prompt and execute it.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

MongoDB shell version: 2.6.5
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group

That’s it, once connected we can issue any MongoDB shell commands. To close the client connection, just fire “exit” command or simply close the command prompt.

MongoDB as Windows Service

The problem with above installation is that we need to start MongoDB server manually and then keep the command prompt open. The solution is to configure it as Windows service, so that it can start as soon as system is up and running. Since it will be running in background, there is no need to keep command prompt open.

Before we configure our MongoDB installation as Windows service, let’s create a configuration file for the MongoDB logs.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Pankaj>cd \

C:\>md MongoDB-logs

Now using echo command we can create a configuration file. If you get any permission issues, then run the command prompt as administrator.

C:\WINDOWS\system32>echo logpath=C:\MongoDB-logs\mongo.log > C:\MongoDB\mongod.conf

Now run below command as administrator to setup MongoDB as service.

C:\>C:\MongoDB\bin\mongod.exe --config C:\MongoDB\mongod.conf --install


If you want to change MongoDB server port or any other configurations, then you can provide them in the above configuration file.

MongoDB Windows Service

If you want to install services for multiple example of mongod.exe, install every service with a unique –serviceName and –serviceDisplayName. Use the multiple examples only when sufficient system resources exist and your design requires it.

Uninstall MongoDB Windows

If you want to remove the MongoDB service, then run below command as administrator.

C:\>C:\MongoDB\bin\mongod.exe --config C:\MongoDB\mongod.conf --remove


That’s all for installing MongoDB on Windows and running it as Windows service. We will look into different MongoDB commands in coming posts.


  1. Ajay Patil says:

    Hi Guys,

    for uninstalling when i run above command on mongodb 3.4 , i am getting below error. and i don’t see mogod.conf file also. Can anyone help here please.

    C:\>C:\mongodb\3.4\bin\mongod.exe –config C:\mongodb\3.4\mongod.conf –remove
    Error reading config file: No such file or directory
    try ‘C:\mongodb\3.4\bin\mongod.exe –help’ for more information

  2. Sunil says:

    A visual demo in Youtube – Mongo 3 installation on Windows. May be helpful

  3. Fatema says:

    C:\……. is not recognised as an internal or external command, operable program or batch file
    this shows wen i try “C:\MongoDB\bin\mongod.exe –config C:\MongoDB\mongod.conf –remove” command.
    i want to remove MongoDB as windows service
    n set it again without any authentication cz wen i try connecting robomongo…authentication issue appears

  4. santhi swaroop says:

    i am getting an error while starting the mongodb service

  5. santhi swaroop says:

    I want to know how to start the MongoDB service.

    when i am trying to start i am getting the error as windows could not start the MongoDB.

    how to resolve it?

  6. Meyer Beck says:

    I’m in the process of installing multiple MongoDB services can you give an example of how one sets up the service. Each one will have it’s own config file that will have a unique data path and log path arguments. Do you use the sc command to set up the services with a unique ServiceName and ServiceDisplayName

    Great Article

  7. Ben says:

    great article. but your title is a little misleading.
    i came here to find out how to remove mongodb for windows but all you talk about is how to remove the windows service, if i chose to use it that way.
    please change your title or add this information on the article.

    1. Pankaj says:

      Once MongoDB service is removed, all you need is to remove MongoDB directory and all its data. That’s it.

  8. Hafeez says:

    C:\>C:\MongoDB\bin\mongod.exe –dbpath D:\test\mongodb\data –config C:\MongoDB\mongod.conf –install

    Without –dbpath the service does not start. complains error. The above line worked for me.

  9. Randy says:

    I have spent over an hour trying to install MongoDB v3.0.4 as a service in Windows. There is much advice on the web but yours if the only one that worked for me. Your time and effort in posting this information is very much appreciated! I will be checking out your Youtube videos now.

  10. Saurabh says:

    Appreciate your efforts

  11. savan says:

    Thank you very much this artical is very helpfull for me.

    Good job boss.

  12. emem umoh says:

    Thank you very much

  13. Well written and really useful, many thanks.

    I had failed with a previous attempt to create a MongoDB service, on Windows 7 you can do this with the command
    sc delete MongoDB

  14. san says:

    I need to know just how can I ge the mongo console ?

  15. Anand says:


Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content