Reposting - Error: Ident authentication failed for user

Reposting - Error: Ident authentication failed for user

我觉得 Unix&Linux 的人流量很慢,所以我也在这里发布这个问题:

我在 CentOS 中安装了 Postgres,以及 Node 和 React with NGINX。按照建议 here,我单独留下了我的 Unix postgres 帐户没有密码。我还用 postgrator 编写了迁移,它在 blog_database.

中创建了一个 table 作为 blog_user

我的 blog_user 具有带加密密码的 LOGIN 属性,数据库 blog_databasepostgres 所有。

当我 运行 在 CentOS 中进行迁移时,我收到此消息

[joseph@vultr backend]$ yarn run migrate
yarn run v1.17.3
$ postgrator --config postgrator-config.js
[2:41:39 AM] table schemaversion does not exist - creating it.
[2:41:39 AM] version of database is: 0
[2:41:39 AM] migrating up to 2
Error: Ident authentication failed for user "blog_user"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

当试图将 allpeer 更改为 md5 时,我需要输入 postgres

的密码
-bash-4.2$ vim /var/lib/pgsql/11/data/pg_hba.conf 
-bash-4.2$ sudo systemctl restart postgresql.service

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for postgres: 
Sorry, try again.

以 root 身份执行重启命令会导致此消息

[root@vultr ~]# vim /var/lib/pgsql/11/data/pg_hba.conf 
[root@vultr ~]# systemctl restart postgresql.service
Failed to restart postgresql.service: Unit not found.

我不确定我需要做什么来解决这个问题。

  1. 对本地连接使用 trust 身份验证,除非计算机上有不受信任的操作系统用户。

  2. PostgreSQL 服务可能有不同的名称。尝试

    systemctl status | grep postgres