Install MongoDB on Windows (installing MongoDB under Windows)

Source: Internet
Author: User
Tags create mongodb documentation install mongodb

Install MongoDB on Windowsoverview

Use the tutorial to install MongoDB on a Windows systems.

PLATFORM Support

Starting in version 2.2, MongoDB does isn't support Windows XP. Please use the more recent version of Windows to use the more recent releases of MongoDB.

IMPORTANT

If you is running any edition of Windows Server R2 or Windows 7, please install a hotfix to resolve an issue with me Mory mapped files on Windows.

Install Mongodb1determine which MongoDB build you need.

There is three builds of MongoDB for Windows:

MongoDB for Windows Server R2 Edition (i.e. 2008R2) runs only on Windows Server R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.

MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server R2 and Windows 7 64-bit.

MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB is only intended for older systems and for use in testing and development systems. 32-bit versions of MongoDB only support databases smaller than 2GB.

To find which version of Windows is running, enter the following command in the command Prompt:

Osarchitecture
2Download MongoDB for Windows.

Download the latest production release of MongoDB from the MongoDB downloads page. Ensure download the correct version of MongoDB for your Windows system. The 64-bit versions of MongoDB does not work with 32-bit Windows.

3Install the downloaded file.

In Windows Explorer, locate the downloaded MongoDB MSI file, which typically are located in the defaultDownloads F older. Double-click the msi file. A set of screens would appear to the through the installation process.

4Move the MongoDB folder to another location (optional).

To move the MongoDB folder, your must issue the move command as an Administrator. For example, to move the folder to C:\mongodb:

Select Start Menu > All Programs > accessories.

Right-click Command Prompt and select Run as Administrator from the popup menu.

Issue the following commands:

CD Move c:\mongodb-win32-* C:\mongodb

MongoDB is self-contained and does not has any other system dependencies. You can run the MongoDB from any folder you choose. You may install the MongoDB in any folder (e.g. D:\test\mongodb)

Run MongoDB

WARNING

Do don't make mongod.exe visible on public networks without running in "Secure Mode" with the authsetting. MongoDB is designed to being run in trusted environments, and the database does not enable ' Secure Mode ' by default.

1Set up the MongoDB environment.

MongoDB requires a data directory to store all data. MongoDB ' s default data directory path is\data\db. Create This folder using the following commands from a Command Prompt:

\data\db  

You can specify a alternate path for data files using the- --dbpath option to Mongod.exe, for example:

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

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

C:\mongodb\bin\mongod.exe--dbpath "D:\test\mongo DB data"
2Start MongoDB.

To start MongoDB, run mongod.exe. For example, from the Command Prompt:

C:\Program Files\mongodb\bin\mongod.exe

This starts the main MongoDB database process. THE waiting for  connections  message in the console output indicates that the  mongod.exe  process is running successfully.

Depending on the security level of your system, Windows could pop up a security Alert dialog box about blocking ' so Me features "of C:\Program files\mongodb\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home or work network and click Allow access. For additional information in security and MongoDB, please see the security documentation.

3Connect to MongoDB.

To connect to MongoDB through the mongo.exe Shell, open another Command Prompt. When connecting, specify the data directory if necessary. This step provides several example connection commands.

If your MongoDB installation uses the default data directory, connect without specifying the data directory:

C:\mongodb\bin\mongo.exe

If you installation uses a different data directory, specify the directory is connecting, as in this example:

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

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

C:\mongodb\bin\mongod.exe--dbpath "D:\test\mongo DB data"

If you want to develop applications using. NET, see the documentation of C # and MongoDB for more information.

4Begin using MongoDB.

To begin using MongoDB, see Getting Started with MongoDB. Also consider the Production notesdocument before deploying MongoDB in a Production environment.

Configure a Windows Service for MongoDB

NOTE

There is a known issue for MongoDB 2.6.0, SERVER-13515, which prevents the use of the instructions in this section. For MongoDB 2.6.0, use manually create a Windows service for MongoDB to create a Windows service for MongoDB instead.

1Configure directories and files.

Create a configuration file and a directory path for MongoDB log output (logpath):

Create a specific directory for MongoDB log files:

"C:\Program Files\mongodb\log"

In the Command Prompt, create a configuration file for the logpath option for MongoDB:

LogPath="C:\Program files\mongodb\mongod.cfg" 
2Run the MongoDB service.

Run all of the following commands in Command Prompt with "Administrative privileges:"

Install the MongoDB service. For --install to succeed, you must specify the logpath run-time option.

---install 

Modify the path to the mongod.cfg file as needed.

Alternate dbpath, specify the path in the configuration file (e.g. C:\ProgramFiles\mongodb\mong Od.cfg) or on the command line with the --dbpath option.

If the dbpath directory does not exist, Mongod.exe would not start. The default value for dbpath is\data\db.

If needed, you can install the services for multiple instances of Mongod.exe or mongos.exe. Install each service with a unique --servicename and --servicedisplayname. Use multiple instances if sufficient system resources exist and your system design requires it.

3Stop or remove the MongoDB service as needed.

To stop the MongoDB service with the following command:

Mongodb

To remove the MongoDB service use the following command:

--remove
Manually Create a Windows Service for MongoDB

The following procedure assumes you has installed MongoDB using the MSI installer, with the default pathC:\Program files\mongodb 2.6 standard.

If you have installed in a alternative directory, you'll need to adjust the paths as appropriate.

1Open an Administrator command prompt. Windows 7/vista/server (and R2)

Press Win + R, then type cmd, then press Ctrl + Shift + enter.

Windows 8

Press Win + X, then press A.

Execute the remaining steps from the Administrator command prompt.

2Create directories.

Create directories for your database and log files:

mkdir C:\data\dbmkdir C:\data\log
3Create a configuration file.

Create a configuration file. This file can include any of the configuration options for Mongod, but mustinclude a valid setting for C2>logpath:

The following creates a configuration file, specifying both the LogPath and the dbpath settings in the C Onfiguration file:

echo logpath=c:\data\log\mongod.log> "C:\Program files\mongodb 2.6 standard\mongod.cfg" Echo dbpath=c:\data\db> > "C:\Program files\mongodb 2.6 standard\mongod.cfg"
4Create the MongoDB service.

Create the MongoDB service.

Sc.exe create MongoDB binpath= "\" C:\Program files\mongodb 2.6 standard\bin\mongod.exe\ "--service--config=\" c \ Program Files\mongodb 2.6 standard\mongod.cfg\ "" displayname= "MongoDB 2.6 standard" start= "Auto"

Sc.exe requires a space between "=" and the configuration values (eg "binpath="), and a "" to escape double quot Es.

If successfully created, the following log message would display:

SUCCESS
5Start the MongoDB service.
Mongodb
6Stop or remove the MongoDB service as needed.

To stop the MongoDB service, use the following command:

Mongodb

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

SC.  MongoDB 

Install MongoDB on Windows (installing MongoDB under Windows)

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: info-contact@alibabacloud.com 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.