我已经通过 shell 创建了用户:
use testDB
db.createUser({user: 'testUser', pwd: 'password', roles: ["readWrite"]})
但用户也可以查看和修改另一个数据库(例如管理员)。我已经检查过db.runCommand({connectionStatus : 1}),“testUser”已记录在会话中。
如何为特定数据库创建具有读写权限的用户?