Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 424
Vladislav Orillo Avatar asked Aug 13 '15 15:08

Vladislav Orillo


2 Answers

work with this:

--authenticationDatabase admin 

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

like image 67
Vladislav Orillo Avatar answered Sep 18 '22 21:09

Vladislav Orillo


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.

like image 24
Milos Matic Avatar answered Sep 20 '22 21:09

Milos Matic