切换到要加密的数据库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