首页 > 解决方案 > STRAPi 连接到 Mongo 数据库时出错。选项的键值对不完整

问题描述

我正在按照文档尝试连接到我的 mongodb atlas 集群,但它给了我一个Error connecting to the Mongo database. Incomplete key value pair for option.

{
  "defaultConnection": "default",
  "connections": {
    "default": {
      "connector": "mongoose",
      "settings": {
        "uri": "mongodb://vafflehauz:Vafflehauz312**?@company-shard-00-00-qreis.mongodb.net:27017,company-shard-00-01-qreis.mongodb.net:27017,company-shard-00-02-qreis.mongodb.net:27017/test?ssl=true&replicaSet=company-shard-0&authSource=admin&retryWrites=true&w=majority"
      },
      "options": {
        "ssl": true
      }
    }
  }
}

这是我的config/development/database.json

我正在使用strapi 3.0.0-beta 版本

标签: mongodbstrapi

解决方案


感谢 Joe Drumgoole 指出我的密码是问题所在,现在它可以工作了。

密码中的问号被解释为 URI 中的一个选项。尝试使用 %3F 代替它。——乔·德拉姆古尔

"uri": "mongodb://vafflehauz:Vafflehauz312**%3F@company-shard-00-00-qreis.mongodb.net:27017,company-shard-00-01-qreis.mongodb.net:27017,company-shard-00-02-qreis.mongodb.net:27017/test?ssl=true&replicaSet=company-shard-0&authSource=admin&retryWrites=true&w=majority"


推荐阅读