db.createUser({
user: "admin",
pwd: "admin@123456",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ],
mechanisms : ["SCRAM-SHA-1"]
})
添加权限
db.updateUser(
"pfnieadmin",
{
roles : [
{"role" : "userAdminAnyDatabase","db" : "admin"},
{"role" : "dbOwner","db" : "admin"},
{"role" : "clusterAdmin", "db": "admin"}
]
}
)
db.auth("admin","admin@123456")