MongoDB安装

1. 首先,当然是下载 MongoDB

MongoDB的官方网站是:http://www.mongodb.org/

最新版本下载在:https://www.mongodb.org/dl/win32/ 。请注意下载适合自己系统的安装包,下载后点击安装。

 

2. 创建数据库文件的存放位置
数据库文件位置: D:\MongoDB\data\db
日志位置: D:\MongoDB\data\log\mongodb.log
执行下面的命令:
mongod --dbpath=D:\MongoDB\data\db --logpath=D:\MongoDB\data\log\mongodb.log --storageEngine=mmapv1 --install
 
  --storageEngine=mmapv1是因为在win7 32位系统下需要更换引擎
 
服务不能启动,需要删除服务再执行上面的命令,sc delete mongodb
 

3.在浏览器中输入网址:http://localhost:27017/ 。如果服务启动成功会看到以下一段话:

 

It looks like you are trying to access MongoDB over HTTP on the native driver port.

 

 

4.回到 Hotfix KB2731284 or later update is not installed这个问题,从官方文档的另一段话:

If you are running any edition of Windows Server 2008 R2 or Windows 7, please installa hotfix to resolve an issue with memory mapped files on Windows.

大意是:如果您运行的是任何版本的Windows Server 2008 R2或Windows 7,请安装修复程序来解决一个内存映射文件在Windows的问题。

程序包:
-----------------------------------------------------------
-----------------------------------------------------------
知识库文章编号:2731284
语言:All (Global)
平台:i386
位置:(http://hotfixv4.microsoft.com/Windows%207/Windows%20Server2008%20R2%20SP1/sp2/Fix405791/7600/free/451412_intl_i386_zip.exe)
 
-----------------------------------------------------------
知识库文章编号:2731284
语言:All (Global)
平台:x64
位置:(http://hotfixv4.microsoft.com/Windows%207/Windows%20Server2008%20R2%20SP1/sp2/Fix405791/7600/free/451413_intl_x64_zip.exe)

 

5.由于每次都要打开mongodb服务,要输入那么一段cmd文字。其实可以将其添加为 服务 来启动。做法如下:

打开cmd, 输入以下文字【注意:路径需和自己的一致,参看第2步骤】

 

sc.exe create MongoDB binPath= "\"D:\mongodb\bin\mongod.exe\" --service --config=\"D:\mongodb\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

如无意外,会看到:CreateService 成功。打开cmd,输入 services.msc,查找 MongoDB 服务,如果能启动成功,则证明路径正确。如果不能启动,则表示 路径错误,需要删除该服务(命令为:sc delete MongoDB),然后重新添加。

  

 
ps:以上参考了多篇网上相关文章
posted @ 2017-02-19 14:07  yours_xin  阅读(140)  评论(0编辑  收藏  举报