Mongo Shell Fails to Connect to the DB Instance, Leaving Message "Authentication failed"
Symptom
An error is reported when you run the following command to connect to a DDS DB instance:
mongo --host 192.168.168.116 --port 8635 -u rwuser -p xxxxxxxxx --authenticationDatabase admin --ssl --sslCAFile /root/ca.crt --sslAllowInvalidHostnames
Error message:
MongoDB shell version v3.4.17 connecting to: mongodb://192.168.168.116:8635/ 2019-09-19T09:39:24.306+0800 W NETWORK [thread1] The server certificate does not match the host name. Hostname: 192.168.168.116 does not match CN: 172.16.2.65 MongoDB server version: 4.0.3 WARNING: shell and server versions do not match 2019-09-19T09:39:24.329+0800 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1461:20 @(auth):6:1 @(auth):1:2 exception: login failed
Possible Cause
The administrator password in the command for connecting to the DDS instance is incorrect.
Solution
- Enter the correct administrator password.
- If you forget the password, reset the password by referring to Resetting the Administrator Password.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.