mongodb 使用mongodump备份 指定用户名密码 出现错误 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed

 

 

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)
[root@MongoDB ~]# lsdb1

 

posted @ 2019-04-13 17:28  minger_lcm  阅读(5558)  评论(0编辑  收藏  举报