Mongo Error: not authorized on dbname to execute command

Mongo Error: not authorized on dbname to execute command

我在 mongolab 上创建了一个帐户,然后创建了数据库和用户。如果我启动 mogno shell 并像这样连接到我的数据库

mongo ***.mlab.com:***/projectname?authMode=scram-sha1 -u myname -p mypass

然后键入 show dbs 我得到这个错误

2017-02-27T20:06:10.834+0200 E QUERY    [thread1] Error: listDatabases failed:{
        "ok" : 0,
        "errmsg" : "not authorized on admin to execute command { listDatabases: 1.0 }",
        "code" : 13
} :

它说我没有被授权但是当我在 mongolab 网站上查看用户配置时它说这个用户有 dbOwner 角色。我如何在数据库中获得授权以便我可以 read/write 数据?

这是因为 monogolab 设置服务器的方式。查看他们的常见问题解答。

http://docs.mlab.com/faq/#i-am-new-to-mongodb---where-do-i-start

In addition, there are certain commands (e.g., “show dbs”), that will not work unless you have a Dedicated plan with full database administrative privileges.

所以你不能运行那个命令,因为你的用户没有这样做的权限。您只有数据库的 dbOwner 角色,而不是管理数据库。