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)