I am trying to connect to MongoDB v4.2.X
using below command and getting the error.
FailedToParse: Password must be URL Encoded for mongodb:// URL: mongodb://user:user@123@localhost:27017/my-employees?authSource=admin try 'mongo --help' for more information
The URL = mongodb://user:user@123@localhost:27017/my-employees?authSource=admin
If your password is user@123
, you're using a special character (a delimeter) in your connection URI. According to the docs:
If the username or password includes the at sign @, colon :, slash /, or the percent sign % character, use percent encoding.
Percent encoding is another name for URL encoding mentioned in your error.
@
will be %40
in percent-encoding, and your connection string would be:
mongodb://user:user%40123@localhost:27017/my-employees?authSource=admin
You can also use this online tool to URL-encode your username/password.