Install MongoDB on Windows)

Source: Internet
Author: User
Tags install mongodb mongodb download mongodb windows windows support

IntroductionBytes ¶

This tutorial provides the installation and running methods on the Microsoft Windows mongodbserver (“mongod.exe ") platform throughCommand PromptAnd general process set up MongoDBAsWindowsService.

Similar to operating on MongoDB on Windows, most components of MongoDB's other platforms share the same operating mode.

ProgramBytes ¶

DownloadMongoDBIsWindowsBytes ¶

Download the latest production version of MongoDB from the MongoDB download page.

Three Versions of MongoDB apply to Windows:

    • MongoDB is applicable to Windows Server 2008 R2 and can only run on Windows Server 2008 R2, 64-bit Windows 7, and new Windows versions. This is built on the Windows platform and cannot run on an earlier version of Windows using the latest enhancements.
    • In MongoDB, Windows runs any 64-bit version of Windows than Windows XP, including Windows Server 2008 R2 and Windows Update 7 64-bit.
    • Any updates than Windows XP running on Windows 32-bit 32-bit version of MongoDB. It is only used for the 32-bit version of the old MongoDB system, used for testing and development systems.

Change in version 2.2: MongoDB does not support Windows XP. Use the latest version of MongoDB for Windows.


You can download the correct version of MongoDB windows at any time. The 64-bit version of MongoDB works with 32-bit windows.

MongoDB's 32-bit version is only applicable to testing and evaluation purposes and supports databases smaller than 2 GB.

You can find the architecture platform of your Windows version and use the followingCommandIn the commandPrompt

Wmic OS get osarchitecture

Find the MongoDB download file in Windows Resource Manager, which is usually in the default download directory. To c: \, right-click archive, and selectExtract all, Browse to c :\.


The folder name is:

C: \ mongodb-win32-i386-[version]


C: \ mongodb-win32-x86_64-[version]

In the two examples, replace the [version] of MongoDB to download

Set EnvironmentBytes ¶

SelectStartTo startCommand Prompt menu, And thenAll programs, And thenAttachmentAnd right-click"Command Prompt",ThenSelectRunAs administratorFrom the pop-up menu. InCommand Prompt, Run the following command:

CD \

Move c: \ mongodb-win32-* c: \ MongoDB


MongoDB is self-contained and runs from any folder you choose without any other system dependencies. You started the investigation analyzer and can install any directory of MongoDB (for example, D: \ test \ MongoDB)

MongoDB requiresData folderTo store its files. The default data directory of MongoDB is c: \ data \ dB. Create this folder and use"Command Prompt". Run the following command sequence:

MD data

MD data \ DB


You can specify a backup path as \ data \ dbdbpathto set mongod.exe, as shown in the following example:

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

If your path contains spaces, enclose the entire path in double quotation. For example:

C: \ MongoDB \ bin \ mongod.exe -- dbpath "D: \ test \ Mongo dB data"

StartMongoDBOfBytes ¶

To start MongoDBCommand PromptRun:

C: \ MongoDB \ bin \ mongod.exe

This will start the process of the primary MongoDB database. The instance runs successfully during the waiting-to-connect message table mongod.exe output on the console.


Based on the security level of your system, Windows will releaseSecurity AlertsIn the dialog box, block some functional "C: \ MongoDB \ bin \ mongod.exe" communication networks. All users should select a private network, such as my home or work network, and click "Allow access ". For additional security and MongoDB information, please read the security and authentication wiki page


You do not need to allow mongod.exe to access the public network, instead of running in "security mode" (that is, authorization ). MongoDB is designed to run in a "trusted environment" and does not enable identity authentication or "security mode" in the database.

Connect the cmd.exe shell used by mongodb. Open anotherCommand PromptAnd issue the following command:

C: \ MongoDB \ bin \ cmd.exe


Run the command to start the c: \ MongoDB \ bin \ mongo.exein a single unique automatically opened mongo.exe shell.Command PromptWindow.

The ingress. exeshell is connected to mongod.exe to run the localhost interface. By default, port 27017 is used. At the cmd.exe prompt at the end of the 19th century, execute the following two commands to insert the default recordSetTest the database and retrieve the record:

> DB. Test. Save ({A: 1 })

> DB. Test. Find ()


Mongo andJavascriptInterface. "If you want to develop and use it. For more information about the language center wiki page, see.

MongoDBAsWindowsServiceBytes ¶

In the new version 2.0.

Installed MongoDBAsWindowsServiceSo that the database is automatically started.


Mongod.exeadds the runtime Windows support service 2.0133, and added support for running Windows Services in version 2.1.1 In cmd.exe.

System ConfigurationBytes ¶

When running apsaradb for MongoDB as a Windows operating system, you must specify two options: log output path and configuration file modification.

    1. Create a specific directory in the MongoDB log file:

MD c: \ MongoDB \ log

    1. Create a configuration file.Command PromptRun the following command:

Echo logpath = c: \ MongoDB \ log \ Mongo. Log> C: \ MongoDB \ mongod. cfg

Although these optional steps are optional, it is good to create a specific location log file and use the configuration file.


Consider setting the logappend option. If this is not the case, mongod.exe will start when you Delete the existing log Content File.

Change in version 2.2: The default Log Path and logappend behavior change in version 2.2.

Installation and runningMongoDBServiceBytes ¶

Run the following command inCommand Prompt"Manage permissions"

    1. Services to install MongoDB:

C: \ MongoDB \ bin \ mongod.exe -- config c: \ MongoDB \ mongod. cfg -- install

Modify the path of the required mongod. cfg file. For-InstallThe option is successfully obtained. YouRequiredSpecify a Log Path or-Log PathRuntime options.

    1. To run MongoDB services:
    2. Net start MongoDB


If you want to use another path for your dbpath in the specified configuration file (for example, c: \ MongoDB \ mongod. cfg)-InstallIn the action you specify. You can also specify-DbpathOn the command line, however, configuration files are always preferred.

If the dbpath'directory does not exist, mongod.exe cannot start. The default dbpath is \ data \ dB.

Stop or deleteMongoDBServiceBytes ¶

    • To stop MongoDB services:
    • Net stop MongoDB
    • Services to delete MongoDB:

C: \ MongoDB \ bin \ mongod.exe -- remove



InstallFor Windows service, you need to "right-click the Administrator to run the command" and set the log and DB configuration items in the configuration file, for example:

Logpath = D: \ MongoDB \ log \ Mongo. Log
Dbpath = D: \ MongoDB \ DB


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.