i installed and setup postgresql-12 with the commands from here [https://www.postgresql.org/download/linux/redhat/]
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql12
yum install postgresql12-server
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
i then tried to log into the database
psql postgres postgres
i got the error
psql: error: could not connect to server: FATAL: Peer authentication failed for user "postgres"
there are two pg_hba.conf files on my system. i checked the authentication settings, shown below, as recommended here [psql: FATAL: Ident authentication failed for user "postgres"
/data/pg_data_dir/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
/var/lib/pgsql/12/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
the authentication settings look OK, so i'm not sure what to do from here.
pg_hba.conf
file -- you can just restart postgres orsu - postgres
before tryingpsql
. Once you get intopsql
, issueselect pg_reload_conf();
– richyenpeer
authentication failed. Thepg_hba.conf
files you show do not include rules using thepeer
authentication method. Are you sure there is no otherpg_hba.conf
file? Check thehba_file
entry in yourpostgresql.conf
file. – clamp