mongodb 设置权限

切换到要加密的数据库
use diary

创建有 readWrite 权限的用户
db.createUser({ user: "youuser", pwd: "youpassword", roles: [{ role: "readWrite", db: "diary" }] })

启用权限验证
./mongod --auth

命令行连接
./mongo -u "youuser" -p "youpassword" --authenticationDatabase diary

url连接
mongodb://youuser:youpassword@localhost:27017/diary

上一篇:linux 修改用户密码的几种方法


下一篇:HDU 6092 17多校5 Rikka with Subset(dp+思维)