MongoDB password with “@” in it

前端 未结 16 2028
遇见更好的自我
遇见更好的自我 2020-11-27 14:03

I\'m trying to connect to a MongoDB database with a username and password using Mongoose in Node.js. All the docs say that the connection string should look like

<         


        
16条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 14:21

    I have also faced the same issue. I have solved by adding encoded password into connection string. And it works just well.

    (1) Encode your password from https://www.url-encode-decode.com
    (2) Replace your password with encoded one.
    (3) It should work well.

    For example:
    Actual Password: ABCDEX$KrrpvDzRTy`@drf.';3X
    Encoded Password: ABCDEX%24KrrpvDzRTy%60%40drf.%27%3B3X

    mongodb://user1:ABCDEX%24KprpvDzRTy%60%40drf.%27%3B3X@dstest.com:1234,ds1234-test.com:19889/mongo-dev?replicaSet=rs-ds123546978&ssl=true',

提交回复
热议问题