您好,登录后才能下订单哦!
1、添加管理用户admin
# mongo
> use admin
> db.addUser('admin','123456')
2、启用认证
# cat /etc/mongodb.conf
fork = true
bind_ip = 192.168.1.10
port = 27017
quiet = true
dbpath = /data/mongodb
logpath = /tmp/mongod.log
logappend = true
journal = true
auth=true #开启认证
3、重启mongod进程
# mongo 192.168.1.10
MongoDB shell version: 2.4.3
connecting to: 192.168.1.10/test
>
>
> use admin
switched to db admin
>
> show collections
Mon May 6 17:18:36.971 JavaScript execution failed: error: {
"$err" : "not authorized for query on admin.system.namespaces",
"code" : 16550
} at src/mongo/shell/query.js:L128
>
> db.auth('admin','123456')
1
>
> show collections
system.indexes
system.users
>
> show dbs
admin 0.203125GB
local 0.078125GB
monitor_log 0.203125GB
test 0.203125GB
>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。