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

work with this:

--authenticationDatabase admin

mongodump and mongorestore commands need the name of database where mongodb user's credentials are stored. (thanks @Zubair Alam)


This should work.

mongodump -h SERVER_NAME:PORT -d DATABASE_NAME -u DATABASE_USER -p PASSWORD

Also this error can popup if username or password are wrong.


mongodump --host <host-ip> --port 27017 --db <database>  --authenticationDatabase admin --username <username> --password <password> --out ./Documents/

After all the trail, I found above working command to dump from mongdb.


mongodump --collection coll_name --db DBname  -u UName -p *** 
          --authenticationDatabase <admin/privileged> --host ip  
          --port portNo  --out foldName