MongoDB Learning (1)-Installing MongoDB in a Windows system

Source: Internet
Author: User
Tags windows 7 x64


Overview


This article mainly describes the method of installing MongoDB on Windows systems.



MongoDB Official website: http://www.mongodb.org/, the latest version is 2.6.7.



Attention:



Starting with version 2.2, MongoDB does not support Windows XP. Please use the latest version of Windows to use the latest version of MongoDB.



If you are running any version of Windows Server R2 or Windows 7, install the hotfix to fix a problem with a memory-mapped file on Windows.



Patch: Official 360 Cloud Disk (access password: 5E1E)


Download installation


The official website provides 32-bit and 64-bit zip-free compression packages and MSI installation packages. Zip download after the extraction to the development of the directory can be used, MSI Click to run, there is no particular need to pay attention to. Both installation is very simple, we need to choose the appropriate version according to their own operating system to download the installation, not mentioned here.



The difference between 32-bit and 64-bit is that 32-bit MongoDB can only hold 2G of data, and 64-bit is unlimited.



I use the operating system is Windows 7 X64,mongodb is the latest 2.6.7 64-bit compression package, the decompression path is D:\MONGODB.


Create a database path


Before you start the MongoDB service, you must manually create a folder that holds the database files, otherwise it cannot be started.






It is known from the error message that because the default database path DBPath (\data\db\) does not exist, we need to create this directory or specify the existing directory in--dbpath.



This article uses the default path to demonstrate, the command to create the \data\db\ directory, the directory location is the root of the MongoDB drive letter, that is, D:\data\db.


D:\mongodb>MD \data\db\


Tips: about the cmd command prompt, recommend a utility gadget: The Windows folder Right-click menu adds "Command Prompt". Reg, refer to the article "add Command Prompt" to the file right-click menu in the Windows system A command prompt window for a directory can be accessed very quickly and easily.


Start MongoDB Service


If the data path is the default \data\db, in the Command Prompt window, start the MongoDB service via the Mongod.exe or Mongod command.



D:\mongodb\bin>mongod
mongod --help for help and startup options
2015-02-07T19:52:55.252+0800 [initandlisten] MongoDB starting : pid=6000 port=27017 dbpath=\data\db\ 64-bit host=fanqi-s550c
2015-02-07T19:52:55.253+0800 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-02-07T19:52:55.253+0800 [initandlisten] db version v2.6.7
2015-02-07T19:52:55.253+0800 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac9899
2015-02-07T19:52:55.253+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack=‘Service Pack 1‘) BOOST_LIB_VERSION=1_49
2015-02-07T19:52:55.253+0800 [initandlisten] allocator: system
2015-02-07T19:52:55.253+0800 [initandlisten] options: {}
2015-02-07T19:52:55.256+0800 [initandlisten] journal dir=\data\db\journal
2015-02-07T19:52:55.257+0800 [initandlisten] recover : no journal files present, no recovery needed
2015-02-07T19:52:55.277+0800 [initandlisten] waiting for connections on port 27017




If the data path is a different path, you need to increase the--dbpath parameter to specify the path. Note that there are spaces in the path, you need to enclose the entire directory in double quotation marks, or you will get an error.


D:\mongodb\bin\mongod.exe--dbpath D:\mongodb\data\db


from the boot information can be learned that MongoDB by default on port 27017 waiting for the connection, we can access the browser through the "http://localhost:27017" to view the relevant information.




To add a MongoDB service to a Windows service


In order not to use MongoDB every time through the CD, Mongod and other commands cumbersome start-up service, we can add it to the Windows service, the specific command is as follows:


D:\mongodb\bin>mongod--logpath=d:\mongodb\logs\mongod.log--install--servicename MongoDB


which



--logpath: Specify the file path to save the log



--install: Installing Windows Services



--servicename: Setting MongoDB service Name



After running, we can open the Windows Service management interface to see the "MongoDB" service, and then how to set the trust we all know,:-).









MongoDB Learning (1)-Installing MongoDB in a Windows system


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.