未授权MongoDB查询-代码13 [英] MongoDB not authorized for query - code 13

查看:436
本文介绍了未授权MongoDB查询-代码13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MongoDB 2.6.1中,我设置了具有dbAdmin权限的用户:

In MongoDB 2.6.1 I've setup a user with dbAdmin rights:

{
        "_id" : "mydbname.myusername",
        "user" : "myusername",
        "db" : "mydbname",
        "credentials" : {
                "MONGODB-CR" : "<some credentials>"
        },
        "roles" : [
                {
                        "role" : "dbAdmin",
                        "db" : "mydbname"
                }
        ]
}

当我使用mongo shell连接到数据库时(在命令行上使用-u和-p)并运行如下查询:

When I use the mongo shell to connect to the database (using -u and -p on command line) and run a query like this:

db.mycollectionname.find()

我收到此错误:

error: { "$err" : "not authorized for query on mydbname.request", "code" : 13 }

有什么想法吗?

到目前为止,我尝试将所有可以找到的角色添加到用户中,但这并没有帮助.

So far I've tried adding every role I can find to the user but that hasn't helped.

推荐答案

您需要分配 read 角色分配给该用户.

You need to assign the read role to the user in question.

dbAdmin 角色包括对非系统集合的读取权限.

The dbAdmin role does not include read access on non-system collections.

这篇关于未授权MongoDB查询-代码13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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