gpt4 book ai didi

mongodb用户认证

转载 作者:可可西里 更新时间:2023-11-01 09:11:27 24 4
gpt4 key购买 nike

db.addUser({ user: "Carlos",
pwd: "pwd",
customData: { employeeId: 12345 },
roles: [
{ role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" },
"readWrite"
]
})

这是 mongo wiki 中的示例设置脚本 http://docs.mongodb.org/manual/reference/method/db.addUser/

这个脚本有什么问题...我得到了

{
"user" : "Carlos",
"pwd" : "ccb9d76967dcb0315ab62e88cb5c372b",
"customData" : {
"employeeId" : 12345
},
"roles" : [
{
"role" : "clusterAdmin",
"db" : "admin"
},
{
"role" : "readAnyDatabase",
"db" : "admin"
},
"readWrite"
],
"_id" : ObjectId("5444963f3507d43d2138fa6f")
}

未捕获的异常:无法添加用户:角色必须是非空字符串。

最佳答案

这适用于 Mongo 2.4.5

db.addUser({ user: "dbOwner",  pwd: "dbOwner", roles: [ "dbOwner", "DBNAME" ]})

关于mongodb用户认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26458841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com