一、得到MongoDBphp
《 從同事處獲得的是兩個exe的,故只需配置一下data的路勁便可html
%cd%\mongod.exe --dbpath %cd%\mongodata
pause 》web
————————————————————————————————mongodb
2014-05-07 以前xp退役,換成win7以後,以前的不能用了(不知道什麼緣由)...shell
因此順便更新一下:apache
Mongodb下載:http://www.mongodb.org/downloads瀏覽器
D:\>cd Mongodb D:\Mongodb>cd bin D:\Mongodb\bin>mongod.exe --install --logpath=D:\Mongodb\log\log.txt --dbpath=D: \Mongodb\db 2014-05-07T15:07:09.755+0800 log file "D:\Mongodb\log\log.txt" exists; moved to "D:\Mongodb\log\log.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:\Mongodb\bin>net start mongodb MongoDB 服務正在啓動 . MongoDB 服務已經啓動成功。 D:\Mongodb\bin>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.less
打開另一個命令窗口ui
D:\Mongodb\bin>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:\Mongodb\bin\>mongod --remove
二、配置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
三、啓動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系統下也遇到這樣的問題,應該是同一類問題,具體解決方案應該相同。