psql: FATAL: password authentication failed for user "icinga"

2.2k views Asked by At

I am trying to setup Icinga 2 on CentOS7 and followed instructions as mentioned in the official document. [https://docs.icinga.com/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/getting-started][1].I have created the database and user as icinga. I am facing the following issue psql: FATAL: password authentication failed for user "icinga" when trying to import the Icinga 2 IDO schema using the below commands

   export PGPASSWORD=icinga and psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql

Below is my pg_hba.conf am using

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# icinga
local   icinga      icinga                            md5
host    icinga      icinga      127.0.0.1/32          md5
host    icinga      icinga      ::1/128               md5
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident
2

There are 2 answers

0
Thanh On

Try to change

local   all             all                                     peer

to:

local   all             all                                     md5
0
Jared Smith On

Had this same issue on Ubuntu Bionic, was able to resolve by adding localhost explicitly as the host:

export PGPASSWORD=icinga
psql -U icinga -d icinga -h localhost < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql