如何使用mongoose连接到mongoDB Atlas

时间:2022-08-31 03:01:59

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?.

我正在尝试通过Mongoose.connect()连接到mongoDB Atlas上的集群,但是每次我尝试连接时都会遇到异常“MongoError:身份验证失败”我知道MongoDB Atlas是新的mongo,因为服务可能不是由猫鼬支持了吗?

1 个解决方案

#1


0  

The answer in this related post is correct. You should:

这篇相关文章的答案是正确的。你应该:

  • not mix options with connection string (if done so)
  • 不要将选项与连接字符串混合(如果这样做)

  • make sure your IP you are running on is whitelisted and your network allows connections to Atlas
  • 确保您运行的IP已列入白名单,并且您的网络允许连接到Atlas

  • make sure the user has sufficient permissions
  • 确保用户具有足够的权限

  • use the connection string as is provided by atlas and just provide it to

    使用atlas提供的连接字符串并将其提供给

    mongoose.connect(uri);
    

#1


0  

The answer in this related post is correct. You should:

这篇相关文章的答案是正确的。你应该:

  • not mix options with connection string (if done so)
  • 不要将选项与连接字符串混合(如果这样做)

  • make sure your IP you are running on is whitelisted and your network allows connections to Atlas
  • 确保您运行的IP已列入白名单,并且您的网络允许连接到Atlas

  • make sure the user has sufficient permissions
  • 确保用户具有足够的权限

  • use the connection string as is provided by atlas and just provide it to

    使用atlas提供的连接字符串并将其提供给

    mongoose.connect(uri);