MongoError:不允许用户执行操作 [英] MongoError: user is not allowed to do action

查看:277
本文介绍了MongoError:不允许用户执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MongoDB Atlas作为数据库.

I am using MongoDB Atlas as my database.

我正在使用带有环回功能的angular4作为api.

I am using angular4 with loopback as api.

我的应用程序可以正常连接到我的数据库.但是,当我尝试获取数据时,出现此错误(我用dbname替换了dbname):

My application connects to my database fine. However, when I try to get data, I get this error (I have replaced my dbname with dbname) :

MongoError: user is not allowed to do action [find] on [dbname.$cmd]

如果我在AWS上使用本地mongodb客户端或mongodb实例,则查询工作正常.但是,使用地图集时,出现此错误.

The query works fine if I use a local mongodb client or a mongodb instance on AWS. However, when using atlas, I get this error.

推荐答案

我自己也遇到了相同的错误.

I had the same error myself.

  • If you are using v.3.0 of the MongoDB NodeJS driver refer to MikaS post for the MongoClient.connect changes that need to be made. https://stackoverflow.com/a/47662979/8775223

要将应用程序连接到Atlas MongoDB,请使用3.4驱动程序,例如.

To connect your application to Atlas MongoDB use the 3.4 driver eg.

mongodb://<USERNAME>:<PASSWORD>@cluster0-shard-00-00-
rb899.mongodb.net:27017,cluster0-shard-00-01-
rb899.mongodb.net:27017,cluster0-shard-00-02-
rb899.mongodb.net:27017/<DBNAME>?ssl=true&replicaSet=Cluster0-shard-
0&authSource=admin

这篇关于MongoError:不允许用户执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆