MongoDB password with “@” in it

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

    Use the options parameter of the mongoose.connect call to specify the password instead of including it in the URL string:

    mongoose.connect('mongodb://localhost/test',
                     {user: 'username', pass: 'p@ssword'},
                     callback);
    

提交回复
热议问题