mongodb创建管理员和指定用户
程序员文章站
2022-07-14 14:39:28
...
1、创建管理员,下面以用户test1为例:
use admin
db.createUser({user: "test1", pwd: "test1", roles: [{role: "userAdminAnyDatabase", db: "admin"}]})
2、创建test2db对应的test2用户:
use test2db
db.createUser({user: "test2", pwd: "test2", roles: [{role: "readWrite", db: "test2db" }]})