how to authenticate mongoose connection mongodb in node.js

前端 未结 7 2091
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 04:38

I have created mongodb user with command

use admin
db.createUser(
    {
      user: \"superuser\",
      pwd: \"12345678\",
      roles: [ \"root\" ]
    }
)
         


        
7条回答
  •  Happy的楠姐
    2021-02-20 05:24

    try this

    const mongooseConnectionString = 'mongodb://superuser:12345678@ localhost/twitter-mongo?authSource=admin'
    

提交回复
热议问题