Mongo DB 3.2身份验证



我刚刚遵循本指南,以使用mongo db设置auth,以及本指南以使用户设置为管理员。

运行mongo> use admin> show users打印以下内容:

{
    "_id" : "admin.root",
    "user" : "root",
    "db" : "admin",
    "roles" : [
        {
            "role" : "root",
            "db" : "admin"
        }
    ]
}

之后,我再次使用--auth运行服务器,并使用以下命令:

mongo -u "root" -p "xxx" --authenticationDatabase "admin"

这将打印以下内容:

MongoDB shell version: 3.2.19
connecting to: test
2018-03-29T15:52:32.329+0200 E QUERY    [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20
@(auth):6:1
@(auth):1:2
exception: login failed

尝试在没有--auth参数的情况下运行此操作,让我可以登录正常。

--auth参数还为我提供了服务器控制台的以下输出:

I ACCESS   [conn1] note: no users configured in admin.system.users, allowing localhost access

但实际上我不确定为什么它不拿起我创建的任何根/管理用户。尝试与Robo 3T连接时,终端会打印以下几个:

I NETWORK  [initandlisten] connection accepted from xxx:44924 #2 (2 connections now open)
I ACCESS   [conn2] SCRAM-SHA-1 authentication failed for root on admin from client xxx ; UserNotFound: Could not find user root@admin
I NETWORK  [conn2] end connection xxx:44924 (1 connection now open

op。

解决方案

通过遵循本文解决的问题。

,尽管连接到服务器时使用了--auth,但通过不评论bindIp: 127.0.0.1行并将authorization: 'enabled'添加到/etc/mongod.conf中的security部分,但我只允许访问本地计算机 - 服务器本身。错误消息的措辞本来可以更好,但这是安全性。我猜。

虽然这是一个非常愚蠢的监督,但我以前没有看过的任何文件涵盖了这个问题。

最新更新