MongoDB3.0.4认证 Query failed with error code 13
dbdao吧
全部回复
仅看楼主
level 2
use admin
......
use my_db
db.createUser(
{user: "test",
pwd: "123321",
roles: [{ role: "userAdmin", db: "my_db" },
{"role":"read",db:"my_db"}
]
}
)
通过Spring-mongodb连接进行操作,是报一下错误:
com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized for query on my_db.player' on server 127.0.0.1:27017。大概的意思是,对my_db中的collection进行读授权,请问如何对collection进行读授权?
2015年07月20日 07点07分 1
level 13
> db.version();
3.0.3
>
>
> use my_db;
switched to db my_db
> db.abc.insert({x:1});
WriteResult({ "nInserted" : 1 })
>
> use my_db
switched to db my_db
> db.createUser(
... {user: "test",
... pwd: "test",
... roles: [{ role: "userAdmin", db: "my_db" },
... {"role":"read",db:"my_db"}
... ]
... }
... )
Successfully added user: {
"user" : "test",
"roles" : [
{
"role" : "userAdmin",
"db" : "my_db"
},
{
"role" : "read",
"db" : "my_db"
}
]
}
>
>
>
dbdao@dbdao-Inspiron-560s:~$ mongo localhost:27017/my_db -u test -p
MongoDB shell version: 3.0.3
Enter password:
connecting to: localhost:27017/my_db
> show collections;
abc
> db.abc.find();
{ "_id" : ObjectId("55acac5f514bf7901f972983"), "x" : 1 }
>
无法通过你上述提供的简单信息 重现该问题, 具体见如上演示
你可以先行使用mongodb shell来验证该问题。
2015年07月20日 08点07分 2
level 1
请问你这个问题解决了吗
2017年11月28日 10点11分 3
1