我在MongoDB上启用了auth并使用以下命令创建了管理员用户:
db.createUser(
{
user: "admin",
pwd: "***",
roles:
[
{ role: "root", db: "admin" },
{ role: "dbAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" },
{ role: "readWrite", db: "deadline7db" },
{ role: "dbOwner", db: "deadline7db" },
{ role: "dbAdmin", db: "deadline7db" },
{ role: "readWrite", db: "admin" },
{ role: "dbOwner", db: "deadline7db_Jobs" },
{ role: "dbOwner", db: "deadline7db_Tasks" },
{ role: "dbAdmin", db: "deadline7db_Jobs" },
]
}
)
当我尝试使用此用户和密码将我的应用程序连接到此数据库时,它正在连接正常但在尝试在deadline7db_Jobs.Job
集合上创建索引时抛出错误。
以下是错误:
命令' createIndexes'失败:未在deadline7db_Jobs上授权执行命令{createIndexes:" Jobs",index:[{ns:" deadline7db_Jobs.Jobs",name:" Stat_1_Props.Pool_1_Props.Grp_1_IsSub_1&# 34;,key:{Stat:1,Props.Pool:1,Props.Grp:1,IsSub:1}}]}(响应:{" ok":0.0," errmsg&# 34;:"未在deadline7db_Jobs上授权执行命令{createIndexes:\" Jobs \",索引:[{ns:\" deadline7db_Jobs.Jobs \",name :\" Stat_1_Props.Pool_1_Props.Grp_1_IsSub_1 \",key:{Stat:1,Props.Pool:1,Props.Grp:1,IsSub:1}}]}",&# 34;代码":13})。
如果我失去任何特权或角色,任何人都可以看看并告诉我。