monodb_在win7上安装MongoDB服务

一、下载mongodb安装程序 *.msi

  在官网页面下载程序:mongodb-win32-x86_64-2008plus-ssl-3.2.6-signed.msi (我当时下载,时间为2016-5-4)

  地址:https://www.mongodb.org/downloads#production

二、使用命令行安装mongodb

  使用管理员权限打开cmd窗口,执行目录到下载的文件目录:(如果你下载的文件在D:\盘,cmd的执行目录也应该在D:\盘)

  执行命令:

msiexec.exe /q /i mongodb-win32-x86_64-2008plus-ssl-3.0.11-signed.msi ^
            INSTALLLOCATION="D:\mongodb" ^
            ADDLOCAL="all"

  INSTALLLOCATION 是 安装目录

  ADDLOCAL 是 要安装的组件 (Server,Router,Client,MonitoringTools,ImportExportTools,MiscellaneousTools) , 对应的二进制可执行文件 (mongod.exe,mongos.exe,mongo.exe,[mongostat.exemongotop.exe],[mongodump.exemongorestore.exemongoexport.exemongoimport.exe],[bsondump.exemongofiles.exemongooplog.exemongoperf.exe])

  例如,还可以这样安装:

msiexec.exe /q /i mongodb-win32-x86_64-2008plus-ssl-3.0.11-signed.msi ^
            INSTALLLOCATION="C:\mongodb" ^
            ADDLOCAL="MonitoringTools,ImportExportTools,MiscellaneousTools"

 

三、运行mongodb 服务

  mongodb默认数据存储在安装目录的根目录的\data\db\目录下,如:mongodb安装在d:\mongodb 目录下,那么对应的默认存储目录就是d:\data\db\目录下.

  创建(分区)根目录下mongodb存储数据目录:

md \data\db

  启动mongodb服务:(cmd执行目录应该在你安装mongodb后的bin目录下)

mongod.exe

  或者其他几种启动方式:

D:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
D:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

  注意:mongodb服务默认是运行在安全的环境中. 参考:https://docs.mongodb.org/v3.0/security/

  停止monogdb的服务,使用Ctrl+C.

 

四、用mongodb客户端连接服务端

  在安装目下的bin文件中:(也就是admin权限运行的cmd窗口执行目录)

mongo.exe

  这就算是连接服务端了,(前提是mongod.exe服务端在运行,默认端口27017未被占用)

  那么现在你就可以看看mongodb的使用指南了,,参考:https://docs.mongodb.org/v3.0/#getting-started

 

五、使用配置文件来安装mongodb到系统服务.

  创建配置文件:参考 https://docs.mongodb.org/v3.0/reference/configuration-options/

  以及需要的目录:

mkdir d:\data\db
mkdir d:\data\log

  创建配置文件: (目录最好在你安装的mongodb目录下,如:D:\mongodb\mongod.cfg)

systemLog:
    destination: file
    path: d:\data\log\mongod.log
storage:
    dbPath: d:\data\db

  执行命令,将mongodb服务安装到系统服务中.

"D:\mongodb\bin\mongod.exe" --config "D:\mongodb\mongod.cfg" --install

  or

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

  启动服务 和 停止服务 :

net start MongoDB

 

net stop MongoDB

  删除系统服务中mongodb服务:

"C:\mongodb\bin\mongod.exe" --remove

  or

sc.exe delete MongoDB

 

  好了,到现在为止你已经安装mongodb到window7系统中.(视系统差别,请参考官方安装指南)

 

本文属于原创,参考来自官方指南:https://docs.mongodb.org/v3.0/tutorial/install-mongodb-on-windows/ (是使用 google 搜索服务喔,^_^)

其他参考 :使用mongoDB的免费开发课程

     .NET平台免费开发课程

     MongoDB构建指南

 

posted @ 2016-05-04 13:33  超超xc  Views(1036)  Comments(0Edit  收藏  举报
I suppose,were childrenonec.