0
我創建了一個名爲學生數據庫中的用戶名和密碼。MongoDB的殼身份驗證錯誤
db.createUser({用戶: '克特林',密碼: '克特林',角色:[{作用: 'userAdmin',DB: '學生'}]});
所以我重新啓動的MongoDB服務器與此命令:
mongod --auth --dbpath C:\data\db
在另一終端
,我連接到與服務器:
mongo
然後查詢的服務器:
> db.getUsers()
[
{
"_id" : "student.Catalin",
"user" : "Catalin",
"db" : "student",
"roles" : [
{
"role" : "userAdmin",
"db" : "student"
}
]
}
]
跑到學生數據庫:
> use student
switched to db student
進入我的用戶名和密碼,通過這個命令成功地:
> db.auth('Catalin','Catalin');
1
,當我想查看我的收藏我得到一個錯誤,爲什麼呢? :
> show collections
2016-03-07T15:54:41.166+0300 E QUERY [thread1] Error: listCollections failed:
{
"ok" : 0,
**"errmsg" : "not authorized on student to execute command { listCollectio
ns: 1.0, filter: {} }",**
"code" : 13
} :
[email protected]/mongo/shell/utils.js:23:13
[email protected]/mongo/shell/db.js:746:1
[email protected]/mongo/shell/db.js:758:15
[email protected]/mongo/shell/db.js:769:12
[email protected]/mongo/shell/utils.js:695:9
[email protected]/mongo/shell/utils.js:594:15
@(shellhelp2):1:1
「errmsg」:「未經學生授權執行命令{listCollectio ns:1.0,filter:{}}「,
P.S. :我正在使用mongoDB 3.2