Mongodb 设置密码

来源:互联网 发布:mac口红畅销的豆沙色 编辑:程序博客网 时间:2024/06/04 20:09
Mongodb 配置用户密码:首先创建admin数据库的用户密码再创建pics的用户名密码> show databases;admin0.203125GBlocal0.078125GBpics0.953125GBtest(empty)> use admin;switched to db admin> db.addUser('pics','xxx');{"_id" : ObjectId("56aadcf700e771cecded4a57"),"user" : "pics","readOnly" : false,"pwd" : "626c9a7149b1a2708fd5a35a1a7f5fd3"重启Mongdodb在没有加--auth的情况下 可以正常访问admin喜爱默认的两个表。启用的时候需要加--auth  /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf --auth  redis01:/root# mongoMongoDB shell version: 2.4.9connecting to: test> use admin;switched to db admin> show tables;Thu Apr 21 15:45:19.616 error: {"$err" : "not authorized for query on admin.system.namespaces","code" : 16550} at src/mongo/shell/query.js:128> use pics;switched to db pics> show tables;Thu Apr 21 15:45:31.008 error: {"$err" : "not authorized for query on pics.system.namespaces","code" : 16550} at src/mongo/shell/query.js:128进入MongoDB:redis01:/root# mongoMongoDB shell version: 2.4.9connecting to: test> use admin;switched to db admin> show tables;Thu Apr 21 16:16:03.812 error: {"$err" : "not authorized for query on admin.system.namespaces","code" : 16550} at src/mongo/shell/query.js:128> db.auth('pics','jh7y,xxx') ;1> show tables;system.indexessystem.usershttp://114.55.x.xx:8080/pics/weixin_qrcode_b_YH.jpghttp://192.168.32.34:8080/pics/q.jpghttp://192.168.32.34/pics/20160421151012b4509158cc6e4136a5af52be573f9b6anginx-gridfs 配置用户名密码:   location /pics/ {                 gridfs                   pics                   field=filename type=string                   user=pics                   pass=jh7y,xxx;   mongo 192.168.32.34:27017;       }redis01:/root# mongofiles -u "pics" -p "xx" -h 192.168.32.34 list -db pics

0 0
原创粉丝点击