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

后端 未结 14 1015
深忆病人
深忆病人 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:30

    The following steps worked for me on MongoDB 3.2:

    1. Check of course if your admin username and pw are correct. You can do this with the mongo shell:

    mongo

    use admin db.auth("admin", "yourpassword")

    If this returns 1, the password is correct.

    1. Then add the role "backup" to your admin (or make sure this role is already added). db.grantRolesToUser("admin", [{ role: "backup", db: "admin" }])

    2. Finally, the mongodump command. It did not work for me when I tried to pass the password as an argument. Instead do this:

    mongodump --username admin --authenticationDatabase admin --db yourmongodatabase

    Then add your password when it promts for it.

    This works for me...

提交回复
热议问题