MongoDB password with “@” in it

前端 未结 16 2018
遇见更好的自我
遇见更好的自我 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:34

    Use this syntax:

    mongoClient.connect("mongodb://username:p%40ssword@host:port/dbname?authSource=admin", { 
            useNewUrlParser: true
        }, function(err, db) {
    
        }
    );
    

提交回复
热议问题