如何使用 mongoose 连接到 mongoDB Atlas [英] How to connect to mongoDB Atlas using mongoose

查看:58
本文介绍了如何使用 mongoose 连接到 mongoDB Atlas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Mongoose.connect() 连接到我在 mongoDB Atlas 上的集群,但是每次我尝试连接时都会收到异常MongoError:身份验证失败"我知道 MongoDB Atlas 是新的 mongo 即服务,mongoose 还不支持它吗?.

I'm trying to connect to my cluster on mongoDB Atlas via Mongoose.connect(), but every time i try to connect i get an exception "MongoError: authentication fail" I know MongoDB Atlas is new mongo as a service could it be not supported by mongoose yet?.

推荐答案

这个相关帖子中的答案是正确的.你应该:

  • 不要将选项与连接字符串混合(如果这样做)
  • 确保您运行的 IP 已列入白名单,并且您的网络允许连接到 Atlas
  • 确保用户有足够的权限
  • 使用由 atlas 提供的连接字符串原样,并将其提供给

mongoose.connect(uri);

这篇关于如何使用 mongoose 连接到 mongoDB Atlas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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