Installing MongoDB under Windows platform

Source: Internet
Author: User
Tags create mongodb

MongoDB for its simple operation, completely free, open source, at any time to download the characteristics, is widely used in a variety of large-scale portals and professional web sites, greatly reducing the operating costs. This paper describes the installation steps and their processes under the Widows platform for your reference.

First, main step 1, view the currently used version of Windows and architecture

WMIC OS Get Caption
WMIC OS get Osarchitecture

2, download the corresponding version

Http://www.mongodb.org/downloads

3, Configuration Mongdb

Create a path to the data file
MD \data\db
You can specify a alternate path for data files using the 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"

4. Start MongoDB

To start MongoDB, run Mongod.exe. For example, from the Command Prompt:
C:\mongodb\bin\mongod.exe
This starts the main MongoDB database process. The waiting for connections message in the console
Output indicates the Mongod.exe process is running successfully.

5. Connect to MongoDB

To connect to MongoDB through the Mongo.exe shell, open another Command Prompt.
C:\mongodb\bin\mongo.exe

6. Terminate MongoDB

Later, to-stop MongoDB, press Control+c in the terminal where the Mongod instance is running

Second, the main components of MongoDB
component set  Binaries---------------- -------------------Server mongod.exe  Router MONGOs .exe  Client mongo.exe  monitoringtools mongostat.exe , Mongotop.exe  importexporttools Mongodump.exe , Mongorestore.exe , Mongoexport.exe , Mongoimport.exe  miscellaneoustools Bsondump.exe , Mongofiles.exe , Mongooplog.exe , Mongoperf.exe  
Third, configure MongoDB as a Windows service
Step1: Open anAdministrator command prompt # # #打开一个命令行窗口Step2: CreateDirectories.# # #创建数据库数据及日志目录mkdir c:\data\db mkdir c:\data\LogStep3: CreateaConfigurationfile # # #创建配置文件CreateaConfigurationfile. ThefileMustSetSystemlog.path. Include Additional configuration options asappropriate. For example,Create a file  atC:\mongodb\mongod.cfg that specifies both Systemlog.path andStorage.dbPath:systemLog:destination:filePath:c:\data\Log\mongod.LogStorage:dbpath:c:\data\dbstep4: Install theMongoDB service. Install theMongoDB Service byStarting Mongod.exe with  the --install option and the-config option toSpecify thePreviously created configurationfile."C:\mongodb\bin\mongod.exe" --config "C:\mongodb\mongod.cfg"--installStep5: Start theMongoDB service. net start MongoDB Step6: StoporRemove theMongoDB Service asNeeded. To stop theMongoDB Service Use theFollowing command:net stop MongoDB to remove theMongoDB Service Use theFollowing command:    "C:\mongodb\bin\mongod.exe" --remove
Iv. Installation Demo 1, installation
C:\Users\1636>wmic os get captionCaptionMicrosoft Windows 7 UltimateC:\Users\1636>wmic os get osarchitectureOSArchitecture64-bit使用下载的msi文件开始安装到指定文件夹,如本例中的D:\MongoDB\Server\3.0\
2. Configure Environment variables
As in this example, D:\mongodb\server\3.0\ BinAdd the path;D to the system environment variable:\mongodb\server\3.0\ BinD:\>mkdir D:\mongodb\dataD:\>D:\mongodb\server\3.0\ Bin\mongod. exe--dbpath D:\mongodb\data2015-10-29t09:26:11.498+0800 I CONTROL Hotfix KB2731284 or later update is not installed, would zero-out data files2015-10 -29t09:26:11.508+0800 I JOURNAL[Initandlisten]Journal Dir=d:\mongodb\data\journal2015-10-29t09:26:11.509+0800 I JOURNAL[Initandlisten]Recover:no journal files present, no recovery needed2015-10-29t09:26:11.611+0800 I Journal[Durability]Durability thread started2015-10-29t09:26:11.613+0800 I JOURNAL[Journal writer]Journal writer thread started2015-10-29t09:26:11.718+0800 I CONTROL[Initandlisten]MongoDB starting:pid=40540 port=27017 Dbpath=d:\mongodb\data64-bit host=hq16362015-10-29t09:26:11.719+0800 I CONTROL[Initandlisten]Targetminos:windows 7/windows Server r22015-10-29t09:26:11.722+0800 I CONTROL[Initandlisten]DB version v3.0.62015-10-29t09:26:11.725+0800 I CONTROL[Initandlisten]git version:1ef45a23a4c5e3480ac919b28afcba3c615488f22015-10-29t09:26:11.728+0800 I CONTROL[Initandlisten]Build Info:windows sys.getwindowsversion (major=6, Minor=1, build=7601, platform=2, service_pack= ' Service Pack 1 ') BOOST _lib_version=1_492015-10-29t09:26:11.731+0800 I CONTROL[Initandlisten]allocator:tcmalloc2015-10-29t09:26:11.737+0800 I CONTROL[Initandlisten]Options{Storage{DbPath: "D:\mongodb\data"} }2015-10-29t09:26:11.906+0800 I NETWORK[Initandlisten]Waiting for connections on port 27017//here has shown that MongoDB has started waiting for a connection to open a separate CMD window, using the MONGO client to connect to the MONGODC:\users\1636>d:\mongodb\server\3.0\ Bin\mongo. exe2015-10-29t09:28:12.427+0800 I CONTROL Hotfix KB2731284 or later update is not installed, would zero-out Datafilesmong ODB Shell version:3.0.6connecting to:test//At this time connected success > Db.version () 3.0.6> show dbslocal 0.078gb//If you need to stop at this time Stop Mongod, you can use CTRL + C directly in the original window
3. Add MongoDB as a Windows service
D:\>mkdir D:\mongodb\dataD:\>mkdir D:\mongodb\logD:\>--Author:leshamid:\>--Blog:http://blog.csdn.net/leshamid:\>Echo Logpath=d:\mongodb\log\mongd.log> "D:\mongodb\mongod. CFG "D:\>Echo Dbpath=d:\mongodb\data>> "D:\mongodb\mongod. CFG "D:\>Type D:\mongodb\mongod. Cfglogpath=d:\mongodb\log\mongd. Logdbpath=d:\mongodb\dataD:\>Sc.exe Create MongoDB binpath= "D:\mongodb\server\3.0\ Bin\mongod. exe--service--config=d:\mongodb\mongod. CFG "[Sc]CreateService SUCCESSD:\>net start mongodbthe MongoDB service is starting. The MongoDB service was started successfully. D:\>net stop mongodbthe MongoDB service is stopping. The MongoDB service was stopped successfully.
4, repair Bug:hotfix KB2731284

https://support.microsoft.com/zh-cn/kb/2731284
Fast installation of MongoDB under Linux

Copyright NOTICE: This article for Bo Master original article, welcome to spread, spread please be sure to indicate the source.

Installing MongoDB under Windows platform

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.