Can't create backup mongodump with --db. Authentication failed

后端 未结 14 969
深忆病人
深忆病人 2020-12-29 18:22

When I create backup of all databases in MongoDB (version 3):

mongodump --username bacUser --password 12345

It\'s OK. But when I try to cre

14条回答
  •  粉色の甜心
    2020-12-29 18:54

    If you use the --uri option, you need to add authSource=admin as a parameter to your connection string (assuming your user is on the admin database)

    mongodump --uri="mongodb://user:pass@host1:27017,host2:27017,host3:27017/?replicaSet=rs0"
    

    Becomes:

    mongodump --db=test --uri="mongodb://user:pass@host1:27017,host2:27017,host3:27017/?replicaSet=rs0&authSoource=admin"
    

提交回复
热议问题