1. 问题所示
在增加mongodb的账号密码时候,实现有误,提示无法增加role这个权限,但明明已经是root的最高权限
> use admin
switched to db admin
> db.createUser({
... user: 'manong',
... pwd: '123456',
... roles:[{
... role: 'root',
... db: 'database'
... }],
... mechanisms : ["SCRAM-SHA-1"]
... })
2022-08-06T00:29:57.805+0800 E QUERY [thread1] Error: couldn't add user: Could not find role: root@database :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
截图如下: