mongoose 通过账号密码连接 Error: Password contains an illegal unescaped character
生活随笔
收集整理的這篇文章主要介紹了
mongoose 通过账号密码连接 Error: Password contains an illegal unescaped character
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
mongoose 遠程連接,我的密碼有亂七八糟的字符,報錯Error: Password contains an illegal unescaped character
報錯的
mongodb: 'mongodb://c666:buyaokan###@ccav.com:27017/zh_db',改成下面,就好啦
mongodb: 'mongodb://' + encodeURIComponent('c666:buyaokan###') + '@ccav.com:27017/zh_db',不要嘗試破解額。
上面的方法可以不報錯,但是實際用的時候,發(fā)現會報錯
name: 'MongoError', message: 'Authentication failed.', ok: 0, errmsg: 'Authentication failed.', code: 18, codeName: 'AuthenticationFailed' }下面才是解決之道 user 要使用創(chuàng)建的admin賬號用戶名
mongoose.connect(mongoDbUri, {auth: { "authSource": "admin" },user: "c666",pass: "c666:buyaokan###",poolSize: 10})特別注意 auth: { "authSource": "admin" }中的authSource添加你對應創(chuàng)建的數據庫。
總結
以上是生活随笔為你收集整理的mongoose 通过账号密码连接 Error: Password contains an illegal unescaped character的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [原]Jenkins(二十) jenki
- 下一篇: Java中文乱码详解