mongorestore[报错]auth error: sasl c onversation error: unable to authenticate using mechanism

完整报错:

2020-06-09T17:42:44.532+0800 error connecting to host: could not connect to server: connection() : auth error: sasl c
onversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.

来由:

mongodb中添加了admin表的用户,即创建了超级管理员(mongodb的安全生产环境的权限设置请查看:
https://blog.csdn.net/Chenftli/article/details/105228130),此时我想去将备份的集合的bson文件数据导入到mongodb指定的数据库时会报出上面的错误。

尝试

尝试使用下面的命令执行

.\mongorestore.exe --host 127.0.0.1 --port 27017 --username 用户名  --password 密码 -d 恢复集合的数据库名 "D:\periodical1.bson"

D:\periodical1.bson为bson数据的路径,执行过后还是报上面的错误

解决:

最后加上下面参数才终于解决问题

--authenticationDatabase admin -u 用户名 -p 密码

实例:

./mongorestore.exe --host 127.0.0.1 --port 27017 --authenticationDatabase admin -u username -p password -d tests "D:\periodical1.bson"

username为用户名,password为密码 ,tests为恢复集合的数据库名

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

橙子园

期待你的鼓励!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值