Tag Archives: mongodb Backup Error

[Solved] mongodb Backup Error: Failed: error getting collections for database `admin`: error running `listCollections`

Backup Command:

# mongodump -h 127.0.0.1:27229 -u root -p pw123456 –authenticationDatabase admin  -o /data/backup/mongoDB

Error Messages:

Failed: error getting collections for database `admin`: error running `listCollections`. Database: `admin` Err: not authorized on admin to execute command { lcursor: {}, $readPreference: { mode: “secondaryPreferred” }, $db: “admin” }

Solution:

> use admin

> db.auth("root","pw123456")

> db.grantRolesToUser ( "root", [ { role: "__system", db: "admin" } ] )  #Grant the admin user permission to execute commands on the system.version table