来自远程节点的 mongodump - 无法使用机制 "SCRAM-SHA-256" 进行身份验证

mongodump from remote node - unable to authenticate using mechanism "SCRAM-SHA-256"

尝试从远程节点获取转储并出现以下错误:

Failed: can't create session: could not connect to server: connection(): auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed) Authentication failed.

尝试了两种方法从远程节点获取转储。但是在这两种方法中都得到了相同的错误。

# 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"

如何解决?

我遇到了同样的问题。在我的例子中,密码有特殊字符。它适用于密码的单引号:

-p 'my_password'

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

   --password 'secret'

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

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

不用说,你只需要更改你的用户名、密码和这个公式中的url就可以了。祝你好运。

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

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


(由 提供)

1.If 您正在为 mongodump 命令使用 URI,--authenticationDatabase admin 选项等同于 ?authSource=admin

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

样本url:

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