【问题标题】:How To Connect Sequelize Node To Amazon RDS Postgres如何将 Sequelize 节点连接到 Amazon RDS Postgres
【发布时间】:2021-10-16 01:21:43
【问题描述】:

我在将 sequelize 连接到 Amazon RDS Postgres DB 时遇到问题。

下面是我的连接字符串:

const dbConfig = new Sequelize(database, username, password, {
  host: host,
  ssl: true,
  dialect: "postgres",
  logging: console.log,
});

这会打印出 ff 错误:

SequelizeConnectionError: password authentication failed for user "USER01"

这个 USER01 是我的本地 postgres 用户名。我什至不知道它为什么要连接到我的本地服务器。

如果我提供 ff 连接字符串:

const dbConfig = new sequelize.Sequelize(database, username, password, {
  host: host,
  ssl: true,
  dialect: "postgres",
  dialectOptions: {
    ssl: "Amazon RDS"
  },
  logging: console.log,
});

我得到 ff 错误:

C:\Users\USER01\Desktop\myproject\node_modules\pg\lib\connection.js:85
        if ('key' in self.ssl) {
                  ^

TypeError: Cannot use 'in' operator to search for 'key' in Amazon RDS
    at Socket.<anonymous> (C:\Users\USER01\Desktop\myproject\node_modules\pg\lib\connection.js:85:19)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

注意:我要证明的连接字符串是我的 Amazon RDS 连接详细信息。

【问题讨论】:

    标签: node.js amazon-web-services sequelize.js amazon-rds


    【解决方案1】:
    dialectOptions: {
        ssl: {
           {rejectUnauthorized: false},
        }
    }
    

    请试试这个

    【讨论】:

    • 这不是关于连接 SSL 而是如何连接,因为我没有 SSL 证书和密钥。即使删除了 SSL 属性,我仍然无法连接到数据库。
    猜你喜欢
    • 2017-04-14
    • 2013-12-05
    • 2021-04-03
    • 1970-01-01
    • 2015-04-10
    • 2016-06-04
    • 1970-01-01
    • 1970-01-01
    • 2015-10-27
    相关资源
    最近更新 更多