使用 mongo 与 mongosh 执行 getCollectionNames() 会导致不同的权限结果

问题描述 投票:0回答:0

(我对 mongo 还很陌生)

我遇到了一个奇怪的 mongo 权限场景,我似乎找不到任何相关信息。当我通过

mongo
vs
mongosh
登录我的 mongo 并运行
db.getCollectionNames()
我得到不同的结果。

  • 使用
    mongo
    登录时,我会得到一个收藏列表
  • 使用
    mongosh
    登录时,我得到:
    • not authorized on db_name to execute command { listCollections: 1, filter: {}, cursor: {}, nameOnly: true, authorizedCollections: false...

我还注意到,当通过

mongosh
登录时,我可以运行
db.runCommand( { listCollections: 1.0, authorizedCollections: true, nameOnly: true } )
并取回收集信息。

我的 mongoDb/mongo shell 是版本 5 和

mongosh
版本 1.8.0。登录后,我确认我正在使用具有相同权限的相同用户。

希望获得有关此行为的更多信息。

mongodb mongo-shell
© www.soinside.com 2019 - 2024. All rights reserved.