admin 发表于 2017-7-24 09:09:55

psql: FATAL: Ident authentication failed for user "username" Error

psql: FATAL: Ident authentication failed for user "username" Error and Solution
I’ve installed Postgresql under Red Hat Enterprise Linux 5.x server. I’ve created username / password and database. But when I try to connect it via PHP or psql using following syntax:sql -d myDb -U username -WIt gives me an error that read as follows:psql: FATAL: Ident authentication failed for user “username”How do I fix this error?

A. To fix this error open PostgreSQL client authentication configuration file /var/lib/pgsql/data/pg_hba.conf :
# vi /var/lib/pgsql/data/pg_hba.conf
This file controls:
[*]Which hosts are allowed to connect
[*]How clients are authenticated
[*]Which PostgreSQL user names they can use
[*]Which databases they can access
By default Postgresql uses IDENT-based authentication. All you have to do is allow username and password based authentication for your network or webserver. IDENT will never allow you to login via -U and -W options. Append following to allow login via localhost only:
local      all      all      trusthost      all      127.0.0.1/32      trust
Save and close the file. Restart Postgresql server:
# service postgresql restart
Now, you should able to login using following command:
$ psql -d myDb -U username -W
页: [1]
查看完整版本: psql: FATAL: Ident authentication failed for user "username" Error