解决方案
在连接数据库字符串后面添加 authSource=admin
image.png
"MongoDB": {
"Host": "mongodb://touchadmin:touchadmin123@127.0.0.1:27017/TouchAdmin?authSource=admin",
"DbName": "TouchAdmin"
}
image.png
use TouchAdmin
db.createUser(
{
user:"touchadmin",
pwd:"touchadmin",
roles:[
{role:"dbOwner", db:"TouchAdmin"}
]
}
)
网友评论