【问题标题】:MongoDB gives "UserNotFound" error when connecting via IPMongoDB 通过 IP 连接时出现“UserNotFound”错误
【发布时间】:2018-08-22 03:41:51
【问题描述】:

我有一个新的 mongoDB 安装。

我已根据此处的指南创建了一个“管理员”用户:https://docs.mongodb.com/manual/tutorial/enable-authentication/

我还按照该指南的第 6 步创建了一个“普通”用户。

当我使用 compass 使用主机名“localhost”和用户名“admin”连接到数据库时,我能够连接。 “普通”用户也是如此。

我正在运行绑定到 IP XXX.XXX.XXX.16 的 mongod 实例,通过以下命令:mongod --auth --port 27017 --bind_ip xxx.xxx.xxx.16

当我将 Compass 中的主机名更改为 XXX.XXX.XXX.16 时,mongod 命令窗口会显示尝试的连接并且连接已被接受...然后显示“UserNotFound:找不到用户 admin@admin” ...并结束连接。

在 Compass 中点击“连接”后完整的 mongod 日志如下所示:

2018-08-21T14:12:50.321-0500 I NETWORK  [initandlisten] waiting for connections on port 27017
2018-08-21T14:13:12.258-0500 I NETWORK  [listener] connection accepted from xxx.xxx.xxx.16:61256 #1 (1 connection now open)
2018-08-21T14:13:12.378-0500 I NETWORK  [conn1] received client metadata from xxx.xxx.xxx.16:61256 conn1: { driver: { name: "nodejs", version: "3.0.7" }, os: { type: "Windows_NT", name: "win32", architecture: "x64", version: "6.2.9200" }, platform: "Node.js v8.2.1, LE, mongodb-core: 3.0.7", application: { name: "MongoDB Compass Community" } }
2018-08-21T14:13:12.385-0500 I ACCESS   [conn1] SASL SCRAM-SHA-1 authentication failed for admin on admin from client xxx.xxx.xxx.xx:61256 ; UserNotFound: Could not find user admin@admin
2018-08-21T14:13:12.488-0500 I COMMAND  [conn1] command admin.system.users appName: "MongoDB Compass Community" command: saslStart { saslStart: 1, mechanism: "SCRAM-SHA-1", payload: "xxx", autoAuthorize: 1, $db: "admin" } numYields:0 ok:0 errMsg:"Authentication failed." errName:AuthenticationFailed errCode:18 reslen:133 locks:{ Global: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 102ms
2018-08-21T14:13:12.491-0500 I NETWORK  [conn1] end connection xxx.xxx.xxx.xxx:61256 (0 connections now open)

我应该注意,当我转到“localhost”时,命令窗口中没有任何内容。

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    我不完全确定为什么......但这解决了问题:

    根据此处的规范构建 mongod.cfg:https://docs.mongodb.com/manual/reference/configuration-options/

    根本没有使用 mongod 命令行的东西......而是只是停止并启动了 windows 服务。

    现在一切正常。

    我的想法是 mongodb 服务正在使用 cfg 文件中的默认值(仅绑定到 127.0.0.1)并且我给出的命令开关被忽略了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-06
      • 1970-01-01
      • 2016-01-05
      • 2019-10-07
      • 2017-02-27
      • 2020-09-16
      • 2016-11-09
      • 2014-07-26
      相关资源
      最近更新 更多