首页 > 解决方案 > 如何连接到 localhost PostgreSQL 数据库?

问题描述

尝试通过 localhost 连接到我的 postgres 数据库时出现授权错误。我可以正常登录sudo -u postgres psql。尝试通过我的 Express 应用程序(同时使用 Sequelize 和 node-postgres)进行连接时,出现错误。

错误:

error: password authentication failed for user: "postgres"

.env:

PGUSER="postgres"
PGHOST=""
PGPASSWORD=""
PGDATABASE=""
PGPORT=""

续集配置:

const sequelize = new Sequelize('postgres://postgres@localhost:5432/test', { ... });

我已经编辑了我的 pg_hba.conf 文件,并接受了所有 localhost 连接:

local all all _BLANK_ trust

标签: node.jspostgresqlsequelize.js

解决方案


推荐阅读