I know this is a basic security measure, but I can't make it works with my mongodb installation. Each time I run the command :
mongorestore dump_folder -u "username" -p "password"
It returns:
error reading database: not authorized on DATABASE_NAME to execute command { listCollections: 1, cursor: { batchSize: 0 } }
My question is : What is the permission that I need to enable and how ?
For the time being, I just turn off the Mongo's security in /etc/mongod.conf and start it back after I restore/dump my databases.
Additional Note: This is how I prepared my databases and its user
- I log in with my admin account, create a database, named DATABASE001
And create a user:
use DATABASE001 db.createUser({ user: "USER001", pwd: "mypassword", roles:[ { role: "readWrite", db: "DATABASE001" },"dbAdmin" ] })
For roles, I add readWrite to DATABASE001 and also dbAdmin
I want this user (USER001) be able to backup or restore his database (DATABASE001).
I tested it by login with this command. It successfully logged in
mongo localhost -u USER001 -p mypassword --authenticationDatabase DATABASE001I want to dump this database content with:
mongodump -u USER001 -p mypassword --authenticationDatabase DATABASE001it throws me an error:
Failed: error getting database names: not authorized on admin to execute command { listDatabases: 1 }
What is this listDatabases ? how can I add it to my roles?