【问题标题】:I can not connect to postgres database我无法连接到 postgres 数据库
【发布时间】:2019-06-02 00:14:59
【问题描述】:

尝试连接数据库时

我的连接属性:

const sequelize = new Sequelize("postgres", "postgres", "postgres", {
  dialect: "postgres",
  host: "127.0.0.1",
  port: "5432",
});   

服务器设置: enter image description here

错误:

{ SequelizeConnectionError: ������������ "postgres" �� ������ �������� ����������� (�� ������)
    at connection.connect.err (E:\Dropbox\BigDeal\BigDealExpressJSTest\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:182:24)
    at Connection.connectingErrorHandler (E:\Dropbox\BigDeal\BigDealExpressJSTest\node_modules\pg\lib\client.js:174:14)
    at Connection.emit (events.js:189:13)
    at Socket.<anonymous> (E:\Dropbox\BigDeal\BigDealExpressJSTest\node_modules\pg\lib\connection.js:126:12)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  name: 'SequelizeConnectionError',

如何解决?

【问题讨论】:

    标签: node.js postgresql express sequelize.js


    【解决方案1】:

    前段时间我只用过一次Sequelize,但我就是这样初始化的。:

    const sequelize = new Sequelize({
        database: 'project-db',
        username: 'postgres',
        password: 'postgres',
        host: 'localhost',
        port: 5432,
        dialect: 'postgres'
    });
    

    编辑:

    阅读 Sequelize 文档,您的连接方式似乎也应该有效。您确定“postgres”(第一个参数)是现有数据库的名称吗?

    【讨论】:

    • 我看到您上传的图片并且该数据库存在,但我认为您错误地对我的答案进行了编辑请求,而不是编辑您的问题。无论如何,我看到它存在并且它似乎已启动并正常工作。我不知道还有什么建议...
    猜你喜欢
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 2016-07-31
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 2019-12-14
    相关资源
    最近更新 更多