时间:2021-07-01 10:21:17 帮助过:22人阅读
writeConcern:
例如 {w: “majority”, j: true, wtimeout: 5000}
Built-In Roles(内置角色):
creatUser例子
创建超级管理员
use admin
db.createUser({
user:"username",
pwd:"password",
roles:["root"]
})
在products数据库创建accountAdmin01用户,拥有readWrite权限,对admin数据库拥有clusterAdmin跟readAnyDatabase权限
use products
db.createUser( { "user" : "accountAdmin01",
"pwd": "cleartext password",
"customData" : { employeeId: 12345 },
"roles" : [ { role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" },
"readWrite"
] },
{ w: "majority" , wtimeout: 5000 } )
use collectionName
db.auth("username",‘password")
show users
db.dropUser("username")
db.changeUserPassword("username","password")
db.createUser(user, writeConcern)
版权声明:本文为博主原创文章,未经博主允许不得转载。
mongodb 学习笔记 05 -- 用户管理
标签:mongodb nosql