【问题标题】:mongodump from remote node - unable to authenticate using mechanism "SCRAM-SHA-256"来自远程节点的 mongodump - 无法使用机制“SCRAM-SHA-256”进行身份验证
【发布时间】:2020-10-29 01:05:19
【问题描述】:

尝试从远程节点进行转储并得到以下错误:

失败:无法创建会话:无法连接到服务器: 连接():身份验证错误:sasl 对话错误:无法 使用机制“SCRAM-SHA-256”进行身份验证:(AuthenticationFailed) 身份验证失败。

尝试了两种方法从远程节点获取转储。但是这两种方法都出现了同样的错误。

# Method 1
mongodump -h remoteip@port -u xxx -p xxx --db xxx --authenticationDatabase xxx

# Method 2
mongodump --uri "mongodb://username:password@remoteip:port/db?authSource=xxx"

如何解决?

【问题讨论】:

  • 错误的凭据或错误的身份验证源或用户不存在,请使用服务器日志确定是哪个。
  • 将错误作为文本添加到问题中。
  • 嗨,我也有同样的问题。我使用与 MongoDB 指南针相同的连接字符串,但使用 mongodump 失败。你是如何解决这个问题的?
  • 也许使用选项 --authenticationDatabase admin 可以解决您的问题。github.com/stefanprodan/mgob/issues/104

标签: mongodb mongodump


【解决方案1】:

1.如果您使用 URI 进行 mongodump 命令,--authenticationDatabase admin 选项等效于?authSource=admin

mongodump --uri "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"

示例网址:

mongodump --uri "mongodb+srv://username1:password1@host1/db1?authSource=admin" 

【讨论】:

    【解决方案2】:

    对我来说(尝试在同一主机上的单个节点数据库上使用 mongodump),使用 --authenticationDatabase admin 就可以了:

    mongodump -u root --password 'secret' --authenticationDatabase admin -d mongo-dev -o /tmp/dump-2020-11-27.bson


    (由mongodump from remote node - unable to authenticate using mechanism "SCRAM-SHA-256"提供)

    【讨论】:

    • 我相信这是正确的答案。您需要使用 --authenticationDatabase 指定 authSource
    • --authenticationDatabase 管理员
    【解决方案3】:

    和你在同一个地方,这样解决了:

    mongodump --uri "mongodb+srv://username:password@yourmongodbclustersourceurl" --archive \
    mongorestore --uri "mongodb+srv://username:password@yourmongodbclusterdestinationurl" --archive \
    --nsExclude "admin.system.*"
    

    不用说,您只需要更改此公式中的用户名、密码和 url,瞧。祝你好运。

    【讨论】:

      【解决方案4】:

      我遇到了同样的问题,并在密码中使用单引号解决了这个问题,如下所示:

         --password 'secret'
      

      【讨论】:

      • 令人惊讶的是,这在 Spring Framework 配置文件中起作用
      【解决方案5】:

      我有同样的问题。就我而言,密码有特殊字符。它适用于密码的单引号:

      -p 'my_password'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-14
        • 2015-10-02
        • 2015-12-20
        • 2022-07-14
        • 1970-01-01
        • 2016-05-30
        • 2015-11-05
        • 1970-01-01
        相关资源
        最近更新 更多