首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mikro-orm错误:用户"postgres“的密码验证失败

Mikro-orm错误:用户"postgres“的密码验证失败
EN

Stack Overflow用户
提问于 2020-08-28 07:00:53
回答 4查看 1.7K关注 0票数 5

我正在尝试沿着这个React GraphQL TypeScript tutorial编写代码

该项目使用MikroOrm与PostgreSQL数据库进行通信。我在我的Ubuntu18.04上安装了PostgreSQL(12.4),创建了一个"postgres“用户,我可以登录到该用户并运行psql,没有任何问题。但是,当我开始使用像npx mikro-orm migration:create (video timestamp)这样的mikro-orm命令时,我得到以下错误:

代码语言:javascript
复制
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日志文件中的错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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我的数据库凭据呢?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2020-08-29 19:20:16

将"md5“改为"trust”,如下所示:

代码语言:javascript
复制
local   all             all                                     peer
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5
票数 6
EN

Stack Overflow用户

发布于 2020-08-28 17:16:34

对我来说,它是在我被添加之后工作的

代码语言:javascript
复制
clientUrl: 'http://localhost:5433'
user: 'postgres',
password: <user pasword for postgres user>

在options对象中

票数 0
EN

Stack Overflow用户

发布于 2021-04-12 19:24:48

This解决方案对我很有效。将userpassword属性添加到mikro-orm配置中:

代码语言:javascript
复制
dbName: "lireddit",
user: "<user_name>",
password: "<password>",
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63625224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档