不能具有UserAdmin或userAdminAnyDatabase权限的用户添加到管理数据库 [英] Cannot add user with userAdmin or userAdminAnyDatabase priviledges to the admin database

查看:1737
本文介绍了不能具有UserAdmin或userAdminAnyDatabase权限的用户添加到管理数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想验证添加到我的本地MongoDB的。

I am trying to add authentication to my local MongoDB.

在我的配置有:

auth = true
setParameter = enableLocalhostAuthBypass=0

我使用执行的mongod 服务器:

/opt/local/bin/mongod --config /Users/gabriel/databases/mongo_data/conf/mongod.conf --setParameter enableLocalhostAuthBypass=0

和以下这些说明,使用本地例外我尝试添加用户:

and following these instructions, using the local exception I try to add the user:

db.addUser({
    user: "username",
    pwd: "password",
    roles: [ "userAdminAnyDatabase" ]
})

结果为n错误:

{
    "user" : "username",
    "pwd" : "aa5469a39788b6c3988537cd409887a1",
    "roles" : [
        "userAdminAnyDatabase"
    ],
    "_id" : ObjectId("52a07b1ee11cb128a47b2a1b")
}
Thu Dec  5 14:09:50.373 couldn't add user: not authorized for insert on admin.system.users at src/mongo/shell/db.js:128

我在做什么错了?

What am I doing wrong?

推荐答案

当你设置你明确地禁止本地主机验证 enableLocalhostAuthBypass = 0 。从配置中删除的setParameter = enableLocalhostAuthBypass = 0 并启动的mongod 没有 - 的setParameter enableLocalhostAuthBypass = 0 和预期都应该工作。

You explicitly forbid localhost authentication when you set enableLocalhostAuthBypass = 0. Remove setParameter = enableLocalhostAuthBypass=0 from configuration and start mongod without --setParameter enableLocalhostAuthBypass=0 and all should work as expected.

这篇关于不能具有UserAdmin或userAdminAnyDatabase权限的用户添加到管理数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆