MongoDB Windows environment Installation and configuration

Source: Internet
Author: User
Tags create mongodb mongodb windows

1. First to the official website (http://www.mongodb.org/downloads) Download the appropriate installation package, the current version is 2.6
Installation package has zip and MSI format, it is recommended to download the ZIP format, the MSI is actually the next decompression, and the installation does not allow the selection of installation path, the default installation to the C:\Program FILES\MONGODB 2.6 standard directory, Choose 32-bit or 64-bit according to your system.

I am the computer is WIN8 system 64-bit, download 64-bit zip package, download completed after extracting to D:\MongoDB directory

To create the database directory D:\MongoDB\data, then open the Command Line window and switch to the D:\MongoDB\bin directory to execute the following command:

Where--dbpath is the specified database storage directory, there are two "-" to be aware of

Mongod--dbpath D:\MongoDB\data

This is a command-line window that prints some startup information, and the last line displays the following information to indicate that the boot was successful.

2014-04-23t10:38:48.391+0800 [Initandlisten] waiting for connections on port 27017

This is the browser input http://localhost:27017/can see the display information for

It looks like you is trying to access MongoDB over HTTP on the native driver port.
Specific as follows:

To this MongoDB is installed, than imagined simple too Doha

MongoDB is installed as a Windows service

Installing MongoDB as a Windows service is simple, just add--install after the command line that you executed above

Mongod--dbpath D:\MongoDB\data--install

According to the normal plot, the service should be installed successfully, but unfortunately, the following prompt appears

--install have to is used with--logpath

As prompted, we need to specify the log directory, so we create the log directory D:\MongoDB\logs and then re-execute the command

Mongod--dbpath D:\MongoDB\data--logpath=d:\mongodb\logs\mongodb.log--logappend

However, the hint still does not specify the log path, after several toss found that this is a 2.6 version of a bug, will be repaired in the next version, then we have two options, one option is to use the previous version of 2.4.9, the other option is to first use 2.4.9 version of the installation successful service, and then upgrade to 2.6 (swollen upgrade? Replace the corresponding 2.4.9 file directly with version 2.6, and we have other options, of course, yes, the answer is yes, using the SC command to create the service, start the service with net start

SC create MongoDB binpath= "D:\MongoDB\bin\mongod.exe--service--dbpath D:\MongoDB\data--logpath=d:\mongodb\logs\ Mongodb.log  --logappend "
net start MongoDB

MongoDB configuration file

Unfortunately, the official download of the installation package does not have a default configuration file, if you want to use the configuration file can only build one, and the other person also recommended to use the configuration file to manage MongoDB configuration, using configuration file configuration database files, log files and some other configuration is at a glance

Unpack the installation package to D:\MongoDB

Set up the database directory D:\MongoDB\data

Create log directory D:\MongoDB\logs

Create profile Directory D:\MongoDB\etc

Setting up the configuration file D:\MongoDB\etc\mongodb.conf

Dbpath=d:\mongodb\data #数据库路径logpath =d:\mongodb\logs\mongodb.log #日志输出文件路径logappend =true #错误日志采用追加模式, When this option is configured, the MongoDB log is appended to the existing log file instead of the new file Journal=true #启用日志文件, Quiet=true #这个选项可以过滤掉一些无用的日志信息 is enabled by default, If you need to debug use set to falseport=27017 #端口号 default to 27017

Only a few common items are specified here, please refer to the official documentation for more detailed configuration http://docs.mongodb.org/manual/reference/configuration-options/

Note: The above directory is the blogger's own set of directories, the official does not have the configuration file path specification, all based on personal preferences to decide

After the configuration files and related directories have been built, use the following method to start MongoDB.

    • Normal Startup
      Mongod--config D:\MongoDB\etc\mongodb.conf
    • Install as a Windows service
      Note: Version 2.6 this way in the Win7, WIN8 64-bit version cannot be installed successfully, other systems are not tested
      Mongod--config D:\MongoDB\etc\mongodb.conf--install
    • Using the SC installation as a Windows service
      SC create MongoDB binpath= "D:\MongoDB\bin\mongod.exe--service--config=d:\mongodb\etc\mongodb.conf"

It is important to note that when a log file is specified, the log is output to the specified log file, regardless of whether it is specified using the configuration file or at the command line, and no log output is visible at the command line interface

Note:

Version 2.6 cannot install Windows Services Bug link https://jira.mongodb.org/browse/SERVER-13515

MongoDB Website: http://www.mongodb.org/

MongoDB Windows environment Installation and configuration

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.