1、获得MongoDB
《 从同事处得到的是两个exe的,故只需配置一下data的路劲即可
%cd%mongod.exe --dbpath %cd%mongodata
pause 》
————————————————————————————————
2014-05-07 之前xp退役,换成win7之后,之前的不能用了(不知道什么原因)...
所以顺便更新一下:
Mongodb下载:http://www.mongodb.org/downloads
D:>cd Mongodb D:Mongodb>cd bin D:Mongodbin>mongod.exe --install --logpath=D:Mongodbloglog.txt --dbpath=D: Mongodbdb 2014-05-07T15:07:09.755+0800 log file "D:Mongodbloglog.txt" exists; moved to "D:Mongodbloglog.txt.2014-05-07T07-07-09". ####
在log.txt中能看到
Creating service MongoDB.
Service creation successful.
Service can be started from the command line via 'net start "MongoDB"'.
###
D:Mongodbin>net start mongodb MongoDB 服务正在启动 . MongoDB 服务已经启动成功。 D:Mongodbin>mongo MongoDB shell version: 2.6.1 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user >
打开http://127.0.0.1:27017/,
可以看到It looks like you are trying to access MongoDB over HTTP on the native driver port.
打开另外一个命令窗口
D:Mongodbin>mongo MongoDB shell version: 2.6.1 connecting to: test >
即连接到mongodb
PS:
1)期间遇到报错:Error connecting to the Service Control Manager:....
用管理员的身份运行即可
2)停止MongoDB Service。
net stop MongoDB
3)删除MongoDB Service。
d:Mongodbin>mongod --remove
2、配置php-mongo
下载php_mongo.dll,版本是php5.2 vc6(对应apache) vc9(对应iis);
Note:我的环境虽然是apache,但是提示Fatal error: Class 'Mongo' not found
,看到php.net上有人说他改用了vc9就可以了,所以尝试了一下,成功了!
修改php.ini extension=php_mongo.dll
重启apache
3、启动mongo服务
cmd进入mongo的安装目录,输入mongod.exe -dbpath ./mongodata 服务端启动成功
cmd进入mongo的安装目录,输入mongo.exe 客户端启动成功
服务器端:
...
Mon Mar 31 15:19:19.156 [initandlisten] waiting for connections on port 27017
Mon Mar 31 15:19:19.156 [websvr] admin web console waiting for connections on po
rt 28017
Mon Mar 31 15:20:11.562 [initandlisten] connection accepted from 127.0.0.1:3197
#1 (1 connection now open)//出现在客户端启动后
Mon Mar 31 15:20:18.781 [PeriodicTask::Runner] task: DBConnectionPool-cleaner to
ok: 21ms客户端:
MongoDB shell version: 2.4.5
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
Mon Mar 31 15:19:18.687 [initandlisten]
Mon Mar 31 15:19:18.687 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Mon Mar 31 15:19:18.687 [initandlisten] ** 32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Mon Mar 31 15:19:18.687 [initandlisten] ** Note that journaling defaults t
o off for 32 bit and is currently off.
Mon Mar 31 15:19:18.687 [initandlisten] ** See http://dochub.mongodb.org/c
ore/32bit
Mon Mar 31 15:19:18.687 [initandlisten]
Mon Mar 31 15:19:18.687 [initandlisten] ** NOTE: your operating system version d
oes not support the method that MongoDB
Mon Mar 31 15:19:18.687 [initandlisten] ** uses to detect impending page f
aults.
Mon Mar 31 15:19:18.687 [initandlisten] ** This may result in slower perfo
rmance for certain use cases
Mon Mar 31 15:19:18.687 [initandlisten]
>
Mongo 命令:
http://www.cnblogs.com/xusir/archive/2012/12/24/2830957.html
http://ithead.iteye.com/blog/1466081
http://blog.csdn.net/zhengshqing/article/details/8686847
http://my.oschina.net/u/572987/blog/99760
http://runfriends.iteye.com/blog/1830749
批量插入 batchInsert: http://www.cnblogs.com/wangtao_20/p/3273679.html
其他可能的问题:
http://www.myexception.cn/database/614108.html
Win7 32下运行MongoDB出错:couldn't connect to server 127.0.0.1 shell/mongo.js:84
第一次在Win7 32下安装了MongoDB,第一次安装(具体安装可以去博客园上找资料很多)一切都能运行成功,但是问题出现了在我重新再去启动MongoDB时系统提 示我 couldn't connect to server 127.0.0.1 shell/mongo.js:84,问题一直不知道怎么回事?最后问题得到解决
- 原因:mongodb不正常关闭造成的mongodb被锁定
- 解决方案:将标识锁定的文件mongod.lock删除,一般这个文件在你安装MongoDB时创建的Data目录下;
重新运行Mongo,此时再去看看data目录下,已经重新又生成一个mongod.lock文件,不用担心这个,在此刻你已经发现没有出错提示,在浏览器输入http://localhost:27017去看看。
http://localhost:28017去看看
注意如果你在Win7 64或者Linux系统下也遇到这样的问题,应该是同一类问题,具体解决方案应该相同。