mongodb-win32-i386-3.0.6 使用
一、下载地址
https://fastdl.mongodb.org/win32/mongodb-win32-i386-3.0.6.zip
二、安装
1. systeminfo
OS 名称: Microsoft(R) Windows(R) Server 2003, Standard Edition
OS 版本: 5.2.3790 Service Pack 2 Build 3790
OS 制造商: Microsoft Corporation
OS 配置: 独立服务器
OS 构件类型: Multiprocessor Free
2. 组件
3. 启动服务前的配置
①配置文件
systemLog: destination: file path: "D:/applications/mongodb/logs/mongodb.log" logAppend: true storage: journal: enabled: true dbPath: "D:/applications/mongodb/data/db" net: port: 27017 security: authorization: disabled
②文件目录
D:\applications\mongodb
├─conf │ mongodb.conf │ ├─data │ └─db └─logs mongodb.log
③安装目录
D:\applications\mongodb-win32-i386-3.0.6
4. 启动服务
Command Prompt:
D:\applications\mongodb-win32-i386-3.0.6\bin>mongod --config D:\applications\mongodb\conf\mongodb.conf
_
5. 查看日志
位置:D:\applications\mongodb\logs\mongodb.log
2015-09-11T15:24:25.826+0800 I CONTROL ***** SERVER RESTARTED *****
2015-09-11T15:24:25.826+0800 I JOURNAL [initandlisten] journal dir=D:/applications/mongodb/data/db\journal
2015-09-11T15:24:25.826+0800 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-09-11T15:24:25.842+0800 I JOURNAL [durability] Durability thread started
2015-09-11T15:24:25.842+0800 I JOURNAL [journal writer] Journal writer thread started
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] MongoDB starting : pid=1444 port=27017 dbpath=D:/applications/mongodb/data/db 32-bit host=pc012
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten]
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal).
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten]
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] targetMinOS: Windows XP SP3
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] db version v3.0.6
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] allocator: tcmalloc
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] options: { config: "D:\applications\mongodb\conf\mongodb.conf", net: { port: 27017 }, security: { authorization: "disabled" }, storage: { dbPath: "D:/applications/mongodb/data/db", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "D:/applications/mongodb/logs/mongodb.log" } }
2015-09-11T15:24:25.857+0800 I INDEX [initandlisten] allocating new ns file D:/applications/mongodb/data/db\local.ns, filling with zeroes...
2015-09-11T15:24:26.060+0800 I STORAGE [FileAllocator] allocating new datafile D:/applications/mongodb/data/db\local.0, filling with zeroes...
2015-09-11T15:24:26.060+0800 I STORAGE [FileAllocator] creating directory D:/applications/mongodb/data/db\_tmp
2015-09-11T15:24:26.060+0800 I STORAGE [FileAllocator] done allocating datafile D:/applications/mongodb/data/db\local.0, size: 64MB, took 0 secs
2015-09-11T15:24:26.060+0800 I NETWORK [initandlisten] waiting for connections on port 27017
6. 使用客户端
①执行mongo
D:\applications\mongodb-win32-i386-3.0.6\bin>mongo
②显示
MongoDB shell version: 3.0.6
connecting to: test
Server has startup warnings:
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten]
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or
less with --journal).
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2015-09-11T15:24:25.857+0800 I CONTROL [initandlisten]
>_
③无授权模式下修改证书机制
1)切换到admin 数据库
2)创建一个admin用户,这时创建的用户证书机制是默认机制5 SCRAM-SHA-1
3)将该用户删除
4)修改证书机制为3 MONGODB-CR(没有创建过用户是查不到证书机制的,也不能修改,所以要执行步骤2 3)
5)创建一个admin用户
6)关闭服务
use admin db.createUser( { user: "admin", pwd: "!QAZ2wsx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) db.system.users.remove({user:"admin"}) db.system.version.update({ "_id" : "authSchema"},{$set: {"currentVersion" : 3} }) db.createUser( { user: "admin", pwd: "!QAZ2wsx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) db.shutdownServer()
补充命令:
> show users { "_id" : "admin.admin", "user" : "admin", "db" : "admin", "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] } > db.system.users.find() { "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "MONGODB-CR" : "3190522a253babf70746f37a40e 36325" }, "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] } > db.system.version.find() { "_id" : "authSchema", "currentVersion" : 3 }
④修改配置文件(authorization: enabled),以授权模式启动,并创建其他数据库的用户
D:\applications\mongodb-win32-i386-3.0.6\bin>mongod --config D:\applications\mongodb\conf\mongodb.conf
D:\applications\mongodb-win32-i386-3.0.6\bin>mongo --port 27017 -u admin -p !QAZ2wsx --authenticationDatabase admin --au
thenticationMechanism MONGODB-CR
use logtest db.createUser( { "user": "xiaoming", "pwd": "123456", "roles":[ { "role": "dbOwner", "db": "logtest" } ] } )
7. MongoVUE 测试