MONGODB3.0以上的用户管理

建立一个超级用户

use admin
db.createUser(
{
user: “sfa”,
pwd: “sfa”,
roles: [ { role: “readWrite”, db: “sfa” } ]
}
)

更新权限:

https://docs.mongodb.org/manual/reference/method/db.grantRolesToUser/#db.grantRolesToUser
db.grantRolesToUser(
“curm”,
[ “readWrite” , { role: “readWrite”, db: “curm” } ],
{ w: “majority” , wtimeout: 4000 }
)

所有权限说明:

https://docs.mongodb.org/manual/reference/built-in-roles/#internal-role

用户管理说明:

https://docs.mongodb.org/manual/reference/method/js-user-management/