How do you change MongoDB user permissions?

前端 未结 2 1428
我在风中等你
我在风中等你 2021-02-12 04:09

For instance, if I have this user:

> db.system.users.find()
{ \"user\" : \"testAdmin\", \"pwd\" : \"[some hash]\", \"roles\" : [ \"clusterAdmin\" ], \"otherDB         


        
2条回答
  •  旧时难觅i
    2021-02-12 04:26

    If you want to just update Role of User. You can do in the following way

    db.updateUser( "userName",
                   {
    
                     roles : [
                               { role : "dbAdmin", db : "dbName"  },
                               { role : "readWrite", db : "dbName"  }
                             ]
                    }
                 )
    

    Note:- This will override only roles for that user.

提交回复
热议问题