添加验证

db.createUser({user:"abc", pwd:"secret_password", roles:[{role:"dbOwner", db:"test"}]})

db.createUser({user:"viewer", pwd:"secret_password", roles:[{role:"read", db:"test"}]})

命令行执行

mongo --eval "db.createUser({user:"abc", pwd:"secret_password", roles:[{role:"dbOwner", db:"test"}]})"
mongo --eval "db.createUser({user:"viewer", pwd:"secret_password", roles:[{role:"read", db:"test"}]})"

验证

db.getUser("viewer")

登陆

./mongo xxx:27017 --authenticationDatabase abc -uabc -ptest

 删除用户

db.dropUser("xxx")
Copyright © opschina.org 2017 with zzlyzq@gmail.com all right reserved,powered by Gitbook该文件修订时间: 2017-07-11 11:32:48

results matching ""

    No results matching ""