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
<
None of the solutions mentioned above worked for me. I researched it further and found out that I had to include the useNewUrlParser parameter.
mongoose.connect(db, {
useNewUrlParser : true
},
err => {
if (err){
console.error('Error: ' + err)
}
else{
console.log('Connected to MongoDb')
}
})
From what I understand, you need a specific version of MongoDB in order to use this. For more details, check Avoid “current URL string parser is deprecated” warning by setting useNewUrlParser to true
It is to get rid of the warning but clearly the version also affect the required parameter.
I haven't tested all special characters but it definitely works with '@#$'.
Hope this helps.