Re: "Failed to connect to Postgres database" - Mailing list pgsql-general

From Marco Ippolito
Subject Re: "Failed to connect to Postgres database"
Date
Msg-id CAFegzBTtnGDhNWNF5J-bkJj9sbdxxxT0cxc0xjwQQZ03y3uusQ@mail.gmail.com
Whole thread Raw
In response to Re: "Failed to connect to Postgres database"  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: "Failed to connect to Postgres database"
List pgsql-general
Thanks Daniel.
After adding the password, now ssh connection to the cluster fabmnet works:

postgres=# \l
                              List of databases
    Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges  
------------+----------+----------+---------+---------+-----------------------
 fabmnet_ca | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
 postgres   | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
 template0  | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
            |          |          |         |         | postgres=CTc/postgres
 template1  | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
            |          |          |         |         | postgres=CTc/postgres
(4 rows)

postgres=# \password
Enter new password:
Enter it again:
postgres=# \q
(base) postgres@pc:~$ psql --cluster 11/fabmnet -h localhost
Password for user postgres:
psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=#

And may be the fact the it's compulsory to add a password is testified also by the fact that changing the ownership of the database while adding a password, lets connect with ssh to the database:

postgres=# CREATE USER fabmnet_admin;
CREATE ROLE
postgres=# ALTER USER fabmnet_admin WITH PASSWORD 'A';
ALTER ROLE

postgres=# ALTER DATABASE fabmnet_ca OWNER TO fabmnet_admin;
ALTER DATABASE
postgres=# \l
                                 List of databases
    Name    |     Owner     | Encoding | Collate |  Ctype  |   Access privileges  
------------+---------------+----------+---------+---------+-----------------------
 fabmnet_ca | fabmnet_admin | UTF8     | C.UTF-8 | C.UTF-8 |
 postgres   | postgres      | UTF8     | C.UTF-8 | C.UTF-8 |
 template0  | postgres      | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
            |               |          |         |         | postgres=CTc/postgres
 template1  | postgres      | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
            |               |          |         |         | postgres=CTc/postgres
(4 rows)

(base) postgres@pc:~$ psql -h localhost --cluster 11/fabmnet
Password for user postgres:
psql: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"
(base) postgres@pc:~$ psql -h localhost --cluster 11/fabmnet -d fabmnet_ca -U fabmnet_admin
Password for user fabmnet_admin:
psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
fabmnet_ca=>


Now I have to fix the interface between fabric-ca and postgresql-11 on both sides. And I will let you know how it is going

Marco

Il giorno ven 27 set 2019 alle ore 13:34 Daniel Verite <daniel@manitou-mail.org> ha scritto:
        Marco Ippolito wrote:

> (base) postgres@pc:~$ psql --cluster 11/fabmnet -h localhost
> Password for user postgres:
> psql: FATAL:  password authentication failed for user "postgres"
> FATAL:  password authentication failed for user "postgres"

Did you set a password for the postgres user in that newly created
cluster?
If not, try psql --cluster 11/fabmnet (without -h localhost),
it should connect you without a password,
then set a password with the \password command in psql,
then try again with -h localhost.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

pgsql-general by date:

Previous
From: Achilleas Mantzios
Date:
Subject: Re: pgq is one of the most underrated pg related stuff
Next
From: Tom Lane
Date:
Subject: Re: pg12 rc1 on CentOS8 depend python2