【问题标题】:Sequelize for Node.js: cannot authenticate for postgresqlSequelize for Node.js:无法为 postgresql 进行身份验证
【发布时间】:2015-01-12 08:09:48
【问题描述】:

我在为 node.js 设置 sequelize 模块时遇到问题。

首先我在postgresql中设置了用户名和密码:

postgres=# CREATE USER testuser WITH PASSWORD 'test';

这是我的初始化代码:

var Sequelize = require('sequelize');
var sequelize = new Sequelize('testdb', 'testuser', 'test', {
    host: 'localhost',
    port: 5342,
    dialect: 'postgres'
});

sequelize.query('select * from mytbl').success(function(tbl){
    console.log('success');
});

但是,当我运行这段简短的代码时,我收到以下错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Failed to authenticate for PostgresSQL. Please double check your settings.

我不确定我做错了什么?如果有人可以提供帮助,将不胜感激。谢谢!

【问题讨论】:

  • Postgres 的日志中有什么内容?
  • /var/log/postgresql/postgresql-9-1-main.log 中的日志似乎没有任何与续集代码相关的内容
  • 尝试使用 CLI 客户端 psql 使用相同的连接信息连接到 Postgres,例如psql -h localhost -U testuser testdb.
  • 嗯,当我以这种方式连接时,看起来一切正常
  • @mathmonkey 如果你这样尝试会发生什么:sequelize = new Sequelize('postgres://testuser:test@localhost:5432/testdb', { dialect: 'postgres', protocol: 'postgres' })

标签: node.js postgresql sequelize.js


【解决方案1】:

当我将端口更改为 5432 时,此示例有效。

【讨论】:

    猜你喜欢
    • 2017-02-18
    • 2018-10-26
    • 2015-07-10
    • 2021-12-26
    • 2016-01-11
    • 2013-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多