【发布时间】:2019-05-30 06:59:48
【问题描述】:
我已经在 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\" }"
我已经在许多在线资源上帮助解决了这个问题,但没有运气,有没有办法解决这个问题?好像我的用户无法访问 admin 数据库,有没有办法将此访问权限授予我的用户,以便我可以运行 show dbs 等必要的命令?
非常感谢任何帮助! :)
【问题讨论】:
-
您为用户分配了什么角色? (见docs.mongodb.com/manual/reference/built-in-roles)
-
@MetalMad 谢谢回复,这里是我给用户申请的角色,角色:["dbAdmin", "read", "readWrite", "dbOwner", "userAdmin"]
标签: mongodb shell authentication roles createuser