Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

mongodb shell login – password contains special characters like -(hyphen) and '(single quote)

I am trying to login to mongodb database using mongodb shell, and if the password contains any special characters like -(hyphen) or ‘(single quote) , it gives error – Error parsing command line: unrecognised option '-8B'df5='.

mongo -u username -p -8B'df5= --authenticationDatabase admin

Kindly help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The manual for the deprecated mongo command makes it clear that the preferred way to pass a connection string is as a URI. https://docs.mongodb.com/manual/reference/connection-string/ makes it clear that usernames and passwords can be passed as part of that URI.

mongo mongodb://username:-8B%27df5%3D@hostname/admin

%27 is the URL-scaping version of '

%3D is the URL-scaping version of =

Python’s urllib.quote() is one of the many ways you can look up these mappings yourself.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading