MongoDB 未授权查询 admin.system.users [英] MongoDB not authorized for query admin.system.users
问题描述
我对 MongoDb 有点陌生,我正在使用 MongoDb v.2.4.这里的问题是,当我使用 --auth 参数运行 mongod 时,即使经过身份验证,我也无法执行简单的操作,例如显示用户".但是如果我在没有 --auth 参数的情况下运行 mongod 就可以了.
I am bit new to MongoDb and I am using MongoDb v.2.4.Here the problem is that when I run the mongod with --auth parameter, even after authenticating I am not able to perform simple operations such as "show users". But works fine if I run mongod without --auth parameter.
> use admin
switched to db admin
> db.auth("dbadmin","mypassword")
1
> show users
**Thu Feb 27 16:50:17.695 error: { "$err" : "not authorized for query on admin.sys
tem.users", "code" : 16550 } at src/mongo/shell/query.js:128**
推荐答案
首先你应该在没有 --auth
的情况下在 localhost 上运行 mongod 并创建必要的用户 角色.在您的情况下,您应该添加 userAdminAnyDatabase
或 userAdmin
角色.您可以使用 --auth
运行 mongod 并由该用户进行身份验证,以便远程访问 system.users
集合.
你可以阅读它 这里.
Firstly you should to run mongod on localhost without --auth
and create user with necessary roles that you needed. In your case you should add userAdminAnyDatabase
or userAdmin
role. Than you could run mongod with --auth
and authenticate by this user for have remote access to system.users
collections.
You could read about it here.
这篇关于MongoDB 未授权查询 admin.system.users的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!