我正在尝试沿着这个React GraphQL TypeScript 教程编写代码
该项目使用 MikroOrm 与 PostgreSQL 数据库进行通信。我在我的 Ubuntu 18.04 上安装了 PostgreSQL(12.4),创建了一个“postgres”用户,我可以登录该用户并运行psql
没有任何问题。但是,当我开始使用(视频时间戳mikro-orm
)之类的命令时,出现以下错误:npx mikro-orm migration:create
error: password authentication failed for user "postgres"
at Parser.parseErrorMessage (/home/<username>/newstack/node_modules/pg-protocol/src/parser.ts:357:11)
at Parser.handlePacket (/home/<username>/newstack/node_modules/pg-protocol/src/parser.ts:186:21)
at Parser.parse (/home/<username>/newstack/node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (/home/<username>/newstack/node_modules/pg-protocol/src/index.ts:7:48)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:483:12)
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) {
length: 104,
severity: 'FATAL',
code: '28P01',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '333',
routine: 'auth_failed'
}
这是 PostgreSQL 日志文件中的错误:
2020-08-28 01:45:18.218 EEST [23088] postgres@newstack FATAL: password authentication failed for user "postgres"
2020-08-28 01:45:18.218 EEST [23088] postgres@newstack DETAIL: Password does not match for user "postgres".
Connection matched pg_hba.conf line 96: "host all all 127.0.0.1/32 md5"
这是我的 pg_hba.conf:
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
我想如果连接是本地的,那么它就不需要密码,但为什么不使用本地套接字呢?如果无法更改,那么我如何为 MikroOrm 提供我的数据库凭据?