Windows下安裝Mongodb的教程

來源:互聯網
上載者:User

1.下載Mongodb

http://www.mongodb.org/downloads

找到自己系統對應的版本,32位或者64位,下載下來

2.將下載的安裝包解壓到你要安裝的目錄

例如:D:\xampp\mongodb,為了方便使用命令列,需要將D:\xampp\mongodb\bin加到系統內容變數的path中。

3.啟動Mongodb

使用mongod --dbpath D:\xampp\mongodb\data命令啟動Mongodb

C:\Users\lxy>mongod --dbpath D:\xampp\mongodb\data
Wed Apr 02 17:09:54.468 [initandlisten] MongoDB starting : pid=12244 port=27017
dbpath=D:\xampp\mongodb\data 64-bit host=IdeaBear-PC
Wed Apr 02 17:09:54.469 [initandlisten] db version v2.4.9
Wed Apr 02 17:09:54.470 [initandlisten] git version: 52fe0d21959e32a5bdbecdc6205
7db386e4e029c
Wed Apr 02 17:09:54.471 [initandlisten] build info: windows sys.getwindowsversio
n(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST
_LIB_VERSION=1_49
Wed Apr 02 17:09:54.471 [initandlisten] allocator: system
Wed Apr 02 17:09:54.472 [initandlisten] options: { dbpath: "D:\xampp\mongodb\dat
a" }
Wed Apr 02 17:09:54.519 [initandlisten] journal dir=D:\xampp\mongodb\data\journa
l
Wed Apr 02 17:09:54.520 [initandlisten] recover : no journal files present, no r
ecovery needed
Wed Apr 02 17:09:54.542 [FileAllocator] allocating new datafile D:\xampp\mongodb
\data\local.ns, filling with zeroes...
Wed Apr 02 17:09:54.542 [FileAllocator] creating directory D:\xampp\mongodb\data
\_tmp
Wed Apr 02 17:09:54.627 [FileAllocator] done allocating datafile D:\xampp\mongod
b\data\local.ns, size: 16MB,  took 0.083 secs
Wed Apr 02 17:09:54.628 [FileAllocator] allocating new datafile D:\xampp\mongodb
\data\local.0, filling with zeroes...
Wed Apr 02 17:09:54.838 [FileAllocator] done allocating datafile D:\xampp\mongod
b\data\local.0, size: 64MB,  took 0.208 secs
Wed Apr 02 17:09:54.840 [initandlisten] command local.$cmd command: { create: "s
tartup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37
297ms
Wed Apr 02 17:09:54.844 [initandlisten] waiting for connections on port 27017
Wed Apr 02 17:09:54.943 [websvr] admin web console waiting for connections on po
rt 28017

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

4.將Mongodb安裝為windows服務

使用命令mongod --logpath D:\xampp\mongodb\log\MongoDB.log --logappend --dbpath D:\xampp\mongodb\data --directoryperdb --serviceName MongoDB --install 安裝服務

Microsoft Windows [版本 6.1.7601]
著作權 (c) 2009 Microsoft Corporation。著作權所有,並保留一切權利。
D:\xampp\mongodb\bin>mongod --logpath D:\xampp\mongodb\log\MongoDB.log --logappend
--dbpath D:\xampp\mongodb\data --directoryperdb --serviceName MongoDB --install
Wed Apr 02 17:23:38.146 Trying to install Windows service 'MongoDB'
Wed Apr 02 17:23:38.546 Service 'MongoDB' (Mongo DB) installed with command line
'D:\xampp\mongodb\bin\mongod.exe --logpath D:\xampp\mongodb\log\MongoDB.log --l
ogappend --dbpath D:\xampp\mongodb\data --directoryperdb --service'
Wed Apr 02 17:23:38.546 Service can be started from the command line with 'net s
tart MongoDB'

啟動MongoDB:net start MongoDB

停止MongoDB:net stop MongoDB

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.