刚接触postsql,选择了一个较新的版本10.4
[root@localhost data]# psql -U postgres postgres
psql: FATAL: Ident authentication failed for user "postgres"
错误如上,su postgres用户是可以登录的。
查网上资料一直都是让我们修改/etc/postsqlxxxxx 文件,但是你会发现etc下面根本就没有这个文件。
10版本以后该文件位置在“/var/lib/pgsql/10/data/pg_hba.conf”,修改这个文件:
79 # "local" is for Unix domain socket connections only
80 local all all md5
81 # IPv4 local connections:
82 host all all 127.0.0.1/32 ident
83 # IPv6 local connections:
84 host all all ::1/128 trust
85 # Allow replication connections from localhost, by a user with the
86 # replication privilege.
87 local replication all peer
88 host replication all 127.0.0.1/32 ident
89 host replication all ::1/128 ident
"/var/lib/pgsql/10/data/pg_hba.conf" 89L, 4268C
重启服务: systemctl start postgresql-10