创建角色:
use xxx
db.createRole(
{
role: "xxx_dbmon_role",
privileges: [
{ resource: { db: "xxx", collection: "system.profile" }, actions: [ "find" ] },
{ resource: { db: "xxx", collection: "" }, actions: [ "listIndexes","listCollections","collStats"] },
{ resource: { db: "xxx", collection: "com.gewara.json.mongo.MaintainInfo" }, actions: [ "find","insert","update","remove" ] }
],
roles: []
}
);
创建用户;
db.createUser(
{
user: "xxx_dbmon",
pwd: "xxx_dbmon",
roles: [
{ role: "xxx_dbmon_role", db:"xxx"}
]})
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/91975/viewspace-1990140/
,如需转载,请注明出处,否则将追究法律责任。