I am trying to login to mongodb database using mongodb shell, and if the password contains any special characters like # or & , the authentication fails.
mongo mongo.cloud.com:8888/database -u username -p a7IF@WV^#66!
mongo mongo.cloud.com:8888/database -u username -p a7IF@WV^&66!
Note: I am using windows command prompt.
If your password contains special characters like #
, &
, |
and other shell special characters, you need to quote it. Additionally, if your password contains a dollar sign, you need to use single quotes around the password to avoid variable interpolation by your shell.
mongo mongo.cloud.com:8888/database -u username -p "a7IF@WV^#66!"
or
mongo mongo.cloud.com:8888/database -u username -p '${password}a7IF@WV^#66!'