安装
1.下载安装,从官网下载winows安装包,安装到d盘(注意路径)
2.由于我安装在d盘,所以在d盘创建文件夹data,里面创建db文件夹
3.启动方法:在D:Program FilesMongoDBServer3.2in下双击mongod.exe,如下则显示正常:
2016-04-15T21:24:08.293+0800 I CONTROL [initandlisten] MongoDB starting : pid=6276 port=27017 dbpath=D:datadb 64-bit host=DESKTOP-LPJTSPF 2016-04-15T21:24:08.295+0800 I CONTROL [initandlisten] targetMinOS: Windows Vista/Windows Server 2008 2016-04-15T21:24:08.295+0800 I CONTROL [initandlisten] db version v3.2.5 2016-04-15T21:24:08.296+0800 I CONTROL [initandlisten] git version: 34e65e5383f7ea1726332cb175b73077ec4a1b02 2016-04-15T21:24:08.296+0800 I CONTROL [initandlisten] allocator: tcmalloc 2016-04-15T21:24:08.296+0800 I CONTROL [initandlisten] modules: none 2016-04-15T21:24:08.296+0800 I CONTROL [initandlisten] build environment: 2016-04-15T21:24:08.297+0800 I CONTROL [initandlisten] distarch: x86_64 2016-04-15T21:24:08.297+0800 I CONTROL [initandlisten] target_arch: x86_64 2016-04-15T21:24:08.297+0800 I CONTROL [initandlisten] options: {} 2016-04-15T21:24:08.297+0800 I - [initandlisten] Detected data files in D:datadb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. 2016-04-15T21:24:08.298+0800 W - [initandlisten] Detected unclean shutdown - D:datadbmongod.lock is not empty. 2016-04-15T21:24:08.298+0800 W STORAGE [initandlisten] Recovering data from the last clean checkpoint. 2016-04-15T21:24:08.299+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0), 2016-04-15T21:24:08.464+0800 I CONTROL [initandlisten] 2016-04-15T21:24:08.465+0800 I CONTROL [initandlisten] ** WARNING: Insecure configuration, access control is not enabled and no --bind_ip has been specified. 2016-04-15T21:24:08.465+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted, 2016-04-15T21:24:08.465+0800 I CONTROL [initandlisten] ** and the server listens on all available network interfaces. 2016-04-15T21:24:08.465+0800 I CONTROL [initandlisten] 2016-04-15T21:24:08.467+0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker 2016-04-15T21:24:08.467+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/data/db/diagnostic.data' 2016-04-15T21:24:08.468+0800 I NETWORK [initandlisten] waiting for connections on port 27017 2016-04-15T21:24:09.023+0800 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK 2016-04-15T21:24:19.975+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:13732 #1 (1 connection now open)
若一闪而过则因为默认在d盘下的data/db文件夹未找到。如果你不想将db放在d:/data/db下也可以指定db位置:
cmd 进入d盘,cd Program FilesMongoDBServer3.2in,mongod.exe dbpath 指定的位置
这样也可以开启数据库。
4.打开客户端。双击bin目录下的mongo.exe,若不闪退则启动成功。
5.测试:
> db test > 1+2 3 > db.runoob.insert({x:10}) WriteResult({ "nInserted" : 1 }) > db.runoob.find() { "_id" : ObjectId("5710e88c34bf37767b29a10e"), "x" : 10 }