mongoDB在windows下的安裝

來源:互聯網
上載者:User

標籤:blog   http   io   os   ar   strong   for   檔案   資料   

下面主要是我在Windows上(Win7)安裝、運行、安裝Windows服務的筆記,以作備忘。

 

1、下載

 

:http://www.mongodb.org/downloads

 

從其下載頁面就可以看出MongoDB還真的是不賴,支援各個作業系統,其驅動也有好多,目前我用的是.net平台的。

 

2、安裝

 

安裝非常簡單,解壓就行了,我解壓後,放在D:/MongoDB目錄下。

 

為了命令列的方便,可以把D:/MongoDB/bin加到系統內容變數的path中了。

 

3、運行

 

D:\>mongod --dbpath D:/MongoDB/data
Sun Oct 24 15:07:05 MongoDB starting : pid=2472 port=27017 dbpath=D:/MongoDB/data 32-bit

** NOTE: This is a development version (1.7.1) of MongoDB.
**       Not recommended for production.

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data

**       see http://blog.mongodb.org/post/137788967/32-bit-limitations

Sun Oct 24 15:07:05 db version v1.7.1, pdfile version 4.5
Sun Oct 24 15:07:05 git version: cee2d0d6816a704126c283401db24c949d5f52a3
Sun Oct 24 15:07:05 sys info: windows (5, 1, 2600, 2, ‘Service Pack 3‘) BOOST_LIB_VERSION=1_35
Sun Oct 24 15:07:05 [initandlisten] waiting for connections on port 27017
Sun Oct 24 15:07:05 [websvr] web admin interface listening on port 28017

 

由於是開發版,上面就有個警告,沒關係,忽略它。

 

最後兩行說明的資料庫連接埠和Web連接埠,分別是27017和28017,在瀏覽器中開啟http://localhost:27017,可以看到其相關的一些資訊。

 

4、安裝Windows服務

 

每次運行mongod --dbpath D:/MongoDB/data命令列來啟動MongoDB實在是不方便,把它作為Windows服務,這樣就方便多了。

 

D:\MongoDB\bin>mongod --logpath D:\MongoDB\logs\MongoDB.log --logappend --dbpath D:\MongoDB\data --directoryperdb --serviceName MongoDB --install
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"‘.

 

注意:這條命令要到MongoDB的bin目錄下運行,剛開始的時 候,我就直接在D:\下運行,結果服務的可執行目錄為【"D:\mongod" --logpath  "D:\MongoDB\logs\MongoDB.log"  --logappend  --dbpath  "D:\MongoDB\data"  --directoryperdb  --service 】,肯定是不對的。

 

該命令列指定了記錄檔:D:\MongoDB\logs\MongoDB.log,日誌是以追加的方式輸出的;

 

資料檔案目錄:D:\MongoDB\data,並且參數--directoryperdb說明每個DB都會建立一個目錄;

 

Windows服務的名稱:MongoDB;

 

以上的三個參數都是可以根據自己的情況而定的,可以通過 mongod --help 查看更多的參數 。

 

最後是安裝參數:--install,與之相對的是--remove

 

啟動MongoDB:net start MongoDB


停止MongoDB:net stop MongoDB

 

以上是我的安裝MongoDB的初體驗,希望能與各位朋友一起學習MongoDB!

mongoDB在windows下的安裝

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.