mongodb 使用mongodump备份 指定用户名密码 出现错误

mongodb 使用mongodump备份 指定用户名密码 出现错误 

[root@MongoDB ~]# mongodump --host 127.0.0.1 --port 27017 -u admin -p 123456 -d db1 -o /root/
 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed

 

解决方法:

添加--authenticationDatabase admin

 

 

 

 

 

再次备份,备份成功

 

[root@MongoDB ~]# mongodump --host 127.0.0.1 --port 27017 -u admin -p 123456 -d db1 -o /tmp/mongobak --authenticationDatabase admin
writing db1.user to 
writing db1.chat to 
done dumping db1.user (3 documents)
done dumping db1.chat (3 documents)
posted @ 2020-03-12 10:00  屌丝的IT  阅读(1409)  评论(0编辑  收藏  举报