mongodump from remote node - unable to authenticate using mechanism "SCRAM-SHA-256"

Viewed 10622

Tried taking dump from a remote node and got the following error:

Failed: can't create session: could not connect to server: connection(): auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed) Authentication failed.

Error Screenshot

Tried two methods to take dump from the remote node. But got the same error in both the methods.

# Method 1
mongodump -h remoteip@port -u xxx -p xxx --db xxx --authenticationDatabase xxx

# Method 2
mongodump --uri "mongodb://username:password@remoteip:port/db?authSource=xxx"

How to resolve this?

5 Answers

I had the same issue. In my case, the password has special characters. It works with single quote for password:

-p 'my_password'

1.If you are using an URI for mongodump command,--authenticationDatabase admin option is equivalent to ?authSource=admin

mongodump --uri "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"

sample url:

mongodump --uri "mongodb+srv://username1:password1@host1/db1?authSource=admin" 

I had the same problem and solved it using single quotes in the password like this:

   --password 'secret'

Was in the same spot that you are, solved it this way:

mongodump --uri "mongodb+srv://username:password@yourmongodbclustersourceurl" --archive \
mongorestore --uri "mongodb+srv://username:password@yourmongodbclusterdestinationurl" --archive \
--nsExclude "admin.system.*"

Needless to mention, you just need to change your username, password and the url in this formula and voila. Good luck.

Related