您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。