数据库

 首页 > 数据库 > MongoDB > 在WIN7下安装使用MongoDB数据库

在WIN7下安装使用MongoDB数据库

分享到:
【字体:
导读:
         摘要:1)、下载MongoDBhttp://downloads.mongodb.org/win32/mongodb-win32-i386-2.4.5.zip下载Windows32-bit版本并解压缩,程序文件都在bin目录中,其它两个目录分别是C++调用是的头文件和库文件。bin目录中包含如下几个程序:1.mongo.exe...

在WIN7下安装使用MongoDB数据库

1)、下载MongoDB
http://downloads.mongodb.org/win32/mongodb-win32-i386-2.4.5.zip

下载Windows 32-bit版本并解压缩,程序文件都在bin目录中,其它两个目录分别是C++调用是的头文件和库文件。bin目录中包含如下几个程序:
1. mongo.exe,命令行客户端工具。
2. mongod.exe,数据库服务程序。
3. mongodump.exe,数据库备份程序。
4. mongoexport.exe,数据导出工具。
5. mongofiles.exe,GridFS工具。
6. mongoimport.exe,数据导入工具。
7. mongorestore.exe,数据库恢复工具。
8. mongos.exe,貌似是性能检测工具。

2)、设置MongoDB目录

将其解压到 d:,再重命名为mongodb,路径为d:mongodb

3)、设置数据文件路径

在d:盘建一个data文件夹,在data文件夹中新建db文件夹,路径d:datadb

4)、启动MongoDB服务

进入 cmd 提示符控制台,
D:mongodbbinmongod.exe --dbpath=d:datadb

Mon Apr 16 08:50:54
Mon Apr 16 08:50:54 warning: 32-bit servers don't have journaling enabled by def
ault. Please use --journal if you want durability.
Mon Apr 16 08:50:54
Mon Apr 16 08:50:54 [initandlisten] MongoDB starting : pid=5084port=27017 dbpat
h=d:datadb 32-bit host=PC-201012302214
Mon Apr 16 08:50:54 [initandlisten]
Mon Apr 16 08:50:54 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are
limited to about 2 gigabytes of data
Mon Apr 16 08:50:54 [initandlisten] **       see http://blog.mongodb.org/post/13
7788967/32-bit-limitations
Mon Apr 16 08:50:54 [initandlisten] **       with --journal, the limit is lower
Mon Apr 16 08:50:54 [initandlisten]
Mon Apr 16 08:50:54 [initandlisten] db version v2.0.4, pdfile version 4.5
Mon Apr 16 08:50:54 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506
cb21f8ebf
Mon Apr 16 08:50:54 [initandlisten] build info: windows sys.getwindowsversion(ma
jor=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB
_VERSION=1_42
Mon Apr 16 08:50:54 [initandlisten] options: { dbpath: "d:datadb" }
Mon Apr 16 08:50:54 [websvr] admin web console waiting for connections on port 2
Mon Apr 16 08:50:54 [initandlisten] waiting for connections on port 27017

MongoDB服务端的默认连接端口:27017

5)、将MongoDB作为 Windows 服务随机启动

先创建D:mongodblogsmongodb.log文件,用于存储MongoDB的日志文件, 再安装系统服务:
D:mongodbbinmongod --dbpath=d:datadb--logpath=d:mongodblogsmongodb.log --install   

(如果提示:Error connecting to the Service Control Manager这种错误,则应该使用管理员身份运行cmd 

 找到命令处理程序C:WindowsSystem32cmd.exe
  右键:以管理员身份运行

all output going to: d:mongodblogsmongodb.log
 Creating service MongoDB.
 Service creation successful.
 Service can be started from the command line via 'net start "MongoDB"'.
 D:>net start mongodb
 Mongo DB 服务已经启动成功。
 D:> 
注意:如果需要卸载服务,执行命令:sc delete MongoDB

6)、客户端连接验证

新打开一个CMD输入:d:mongodbbinmongo,如果出现下面提示,那么您就可以开始MongoDB之旅了:

d:mongodbbinmongo  
MongoDB shell version: 2.0.4  
connecting to: test  

7)、查看MongoDB日志

查看D:mongodblogsmongodb.log文件,即可对MongoDB的运行情况进行查看或排错。

 http://localhost:27017/可以看到如下提示:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
如此,MongoDB数据库服务已经成功启动了。

http://localhost:28017/管理

在WIN7下安装使用MongoDB数据库
分享到:
在Python程序中连接MongoDB数据库
在Python程序中连接MongoDB数据库 本文是一个Python 使用MongoDB的简单教程,将使用pymongo对MongoDB进行的各种操作进行了简单的汇总,我们进行了简单整理,使用Python的同学可以看一看。 下载相应平台的版本,解压即可。为方便使用,将bin路径添加到系统path环境变量里。其中mongod是服务器,mongo是客户shell,然后创...
MongoDB的性能优势
MongoDB的性能优势 最近开始研究MySQL和MongoDB,发现这方面资料不多。尤其是真正的说到点子上的文章,太少了。 有一些对比测试的文章基本上都是瞎测,测试方法都测到了马腿上,得出的结论基本上都是NoSQL毫无价值 容我借用Russell Smith 的那句话:不是MongoDB不行,是你不懂。 让我来分析一下MongoDB的真正性能...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……