http://www.cnblogs.com/snake-hand/p/3172376.html
1)、下載MongoDBhttp://downloads.mongodb.org/win32/mongodb-win32-i386-2.4.5.zip
下載Windows 32-bit版本并解壓縮,程序文件都在bin目錄中,其它兩個目錄分別是C++調用是的頭文件和庫文件。bin目錄中包含如下幾個程序:
1. mongo.exe,命令行客戶端工具。
2. mongod.exe,數(shù)據(jù)庫服務程序。
3. mongodump.exe,數(shù)據(jù)庫備份程序。
4. mongoexport.exe,數(shù)據(jù)導出工具。
5. mongofiles.exe,GridFS工具。
6. mongoimport.exe,數(shù)據(jù)導入工具。
7. mongorestore.exe,數(shù)據(jù)庫恢復工具。
8. mongos.exe,貌似是性能檢測工具。
2)、設置MongoDB目錄
將其解壓到 d:\,再重命名為mongodb,路徑為d:\mongodb
3)、設置數(shù)據(jù)文件路徑
在d:盤建一個data文件夾,在data文件夾中新建db文件夾,路徑d:\data\db
4)、啟動MongoDB服務
進入 cmd提示符控制臺,
D:\mongodb\bin\mongod.exe --dbpath=d:\data\db
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=27017dbpat
h=d:\data\db32-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:\data\db" }
Mon Apr 16 08:50:54 [websvr] admin web console waiting for connections on port 2
8017
Mon Apr 16 08:50:54 [initandlisten] waiting for connections on port 27017
MongoDB服務端的默認連接端口:27017
5)、將MongoDB作為 Windows 服務隨機啟動
先創(chuàng)建D:\mongodb\logs\mongodb.log文件,用于存儲MongoDB的日志文件, 再安裝系統(tǒng)服務:
D:\mongodb\bin\mongod--dbpath=d:\data\db--logpath=d:\mongodb\logs\mongodb.log --install
(如果提示:Error connecting to the Service Control Manager這種錯誤,則應該使用管理員身份運行cmd
找到命令處理程序C:\Windows\System32\cmd.exe
右鍵:以管理員身份運行
)
all output going to: d:\mongodb\logs\mongodb.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服務已經(jīng)啟動成功。D:>
注意:如果需要卸載服務,執(zhí)行命令:sc delete MongoDB
6)、客戶端連接驗證
新打開一個CMD輸入:d:\mongodb\bin\mongo,如果出現(xiàn)下面提示,那么您就可以開始MongoDB之旅了:
d:\mongodb\bin\mongo
MongoDB shell version: 2.0.4
connecting to: test
7)、查看MongoDB日志
查看D:\mongodb\logs\mongodb.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數(shù)據(jù)庫服務已經(jīng)成功啟動了。