我在为 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.
我不确定我做错了什么?如果有人可以提供帮助,将不胜感激。谢谢!
最佳答案
当我将端口更改为 5432 时,此示例有效。
关于node.js - Node.js 的 Sequelize : cannot authenticate for postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20703887/