MongoDB用户管理

技术运维MongoDB 432

用户权限:

read
readWrite
dbAdmin
userAdmin
clusterAdmin
readAnyDatabase
readWriteAnyDatabase
userAdminAnyDatabase
dbAdminAnyDatabase

创建用户:

db.createUser(user, writeConcern)

db.createUser({ user: "user",
  pwd: "pass",
  roles: [
    { role: "read", db: "database" } 
  ]
})

更新用户:

db.updateUser("user",{
  roles: [
    { role: "readWrite", db: "database" } 
  ]
})

删除用户:

db.removeUser("user")

or

db.dropUser("user")

用户列表:

db.getUsers();

Post Comment