1

I have a documentdb cluster, I m unable to connect to documentDB when I pass username and password args at once

mongo --host <myDocDbHost>:27017 --username admin --password <myPassword> I get following error

connecting to: mongodb://< myDocDbHost>:27017/?gssapiServiceName=mongodb
2021-10-26T21:09:17.228+0000 E QUERY    [js] Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:356:17
@(connect):2:6
exception: connect failed

Where as when I try mongo --host <myDocDbHost>:27017 --username admin and enter password in next prompt where it asks for Password I m able to connect. I verified that I m using the correct password in both cases. I had same issue when I tried to connect directly from EC2 instance in same VPC as documentDB and through ssh tunneling as well. Can someone help me connect to db by passing both username and password args at once

saketh
  • 803
  • 1
  • 10
  • 24
  • 1. `mongo` is the shell not db, 2. Does you password have special symbols? – dododo Oct 27 '21 at 01:11
  • try this : mongo --host HOST --port PORT -u USERNAME -p PASSWORD – Mahdad Oct 27 '21 at 04:13
  • See https://stackoverflow.com/questions/63754742/authentication-failure-while-trying-to-save-to-mongodb/63755470#63755470 The (default) Authentication database depends on the connection string. – Wernfried Domscheit Oct 27 '21 at 05:22
  • Found the issue its due to special chars in password. I m able to login now. I updated password to not have any special chars thanks all – saketh Oct 27 '21 at 15:36

0 Answers0