在 mongodb atlas 实例中 运行 db.command("usersInfo") 时出现授权错误

Authorization error while running db.command("usersInfo") in a mongodb atlas instance

在 Atlas mongo 数据库实例上获取 "pymongo.errors.OperationFailure: not authorized on admin to execute command"。

虽然我 运行 在本地 mongo 数据库实例上执行相同的命令,但我没有收到错误。

db.command("usersInfo")

这在 Atlas 共享层 (M0/M2/M5) 中是预期的。参见:

关于usersInfo

This command can only be called with arguments:
{user: <MYUSER>, db: 'admin'}

本地 MongoDB 实例不会有此限制,因为保护部署的安全完全是您的责任,因此不受像 Atlas 这样严格的安全默认设置的约束。