小编Hel*_*elp的帖子

MongoDB - 无权执行命令

我已成功启用 MongoDB 上的授权,并在 admin 数据库上创建了一个帐户,然后为我的数据库创建了一个名为 test 的帐户。连接到我的测试数据库的以下连接字符串成功运行:mongo --host 192.168.17.52 --port 27017 -u user1 -p password --authenticationDatabase test

我现在唯一的问题是,我无法执行诸如:show dbs 之类的命令。当我尝试这样做时,我收到以下错误:

"errmsg" : "not authorized on admin to execute command { listDatabases: 1.0, lsid: { id: UUID(\"a1d5bc0d-bc58-485e-b232-270758a89455\") }, $db: \"admin\" }"
Run Code Online (Sandbox Code Playgroud)

我一直在许多在线资源上帮助解决这个问题,但没有运气,有没有办法解决这个问题?似乎我的用户无法访问 admin 数据库,有没有办法将此访问权限授予我的用户,以便我可以运行 show dbs 之类的必要命令?

任何帮助深表感谢!:)

authentication shell roles mongodb createuser

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

authentication ×1

createuser ×1

mongodb ×1

roles ×1

shell ×1