Can't create backup mongodump with --db. Authentication failed
65,871
Solution 1
work with this:
--authenticationDatabase admin
mongodump and mongorestore commands need the name of database where mongodb user's credentials are stored. (thanks @Zubair Alam)
Solution 2
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.
Solution 3
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.
Solution 4
mongodump --collection coll_name --db DBname -u UName -p ***
--authenticationDatabase <admin/privileged> --host ip
--port portNo --out foldName
Solution 5
mongodump --authenticationDatabase admin -uroot -pyourpassword
here root is username and yourpassword is your password.
This command will backup/dump all database back-up in current directory.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on July 05, 2022Comments
-
Admin almost 2 years
When I create backup of all databases in MongoDB (version 3):
mongodump --username bacUser --password 12345
It's OK. But when I try to create backup of a selected db:
mongodump --username bacUser --password 12345 --db test
It gives me this error:
Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.