Issue Description
When connecting to the DDS instance using client, the error "Authentication failed" is reported, and the connection command used is as follows:
mongo "mongodb://root:<password>@<IP1:Port1>,<IP2:Port2>/admin?authSource=admin&replicaSet=<setname>"
The error message is as follows:
2023-07-19T11:23:54.055+0800 E QUERY [js] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20 @(auth):6:1 @(auth):1:2 exception: login failed
Cause Analysis
The error "Authentication failed" indicates that there is no problem with network access from the client to the DDS instance. Generally, the problem may be as follows:
• Wrong password.
• Username and password do not match.
• The password contains special characters.
Solution
Confirm that the username and password you entered are correct, and try again with the correct username and password.
If you forget the password, you can reset it on the DDS console.
Interactive verification can be used to verify whether it is a problem of special character. An example of interactive verification is as follows, which is characterized by not specifying password information in the Connection URI.
mongo "mongodb://root@<IP1:Port1>,<IP2:Port2>/admin?authSource=admin&replicaSet=<setname>"
After executing the above command, you will be prompted to enter further password information. If interactive verification is successful but verification fails by directly placing the password in the Connection URI, it is very likely that the password contains special characters.
Special characters are handled by lifting the manually escaped password in the Connection URI, replacing '%' with '% 25', '@' with '%40', '!' with '%21'. That is to say, replace special characters with '%' + hexadecimal ASCII code.