ReimuHakurei / phpPgAdmin

Actively maintained fork of phpPgAdmin.
GNU General Public License v2.0
102 stars 24 forks source link

pg_connect(): Unable to connect to PostgreSQL server: FATAL: Passwort-Auth failed #17

Closed twistios closed 12 months ago

twistios commented 1 year ago

I created a new user for my database. When trying to login I get an error-message.

I was able to reproduce it with a super simple user: Username: "test", password: "test", all rights (superuser, ...) This is the message I get on a try to sign-in (translated):

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Passwort-Authentification for user test
failed in D:\Programme\XAMPP\phpPgAdmin\libraries\adodb\drivers\adodb-postgres64.inc.php on line 747

I already tried to adapt the pg_hba.conf but it did not help. When I change the file to this (I read that changing "local" to "host" might help, maybe because of Windows)

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
host   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
host   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

I get a new error:

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: could not load D:/Programme/PostgreSQL/16/data/pg_hba.conf
in D:\Programme\XAMPP\phpPgAdmin\libraries\adodb\drivers\adodb-postgres64.inc.php on line 747

Using the build-in user "postgres" is working fine (password created on install).

Info:

ReimuHakurei commented 1 year ago

I would advise checking PostgreSQL's logs (not sure where those are stored on Windows) -- it will likely contain additional details.

twistios commented 1 year ago

This is from the log (located in "D:\Programme\PostgreSQL\16\data\log" in my case, message translated again).

2023-10-17 16:27:07.564 CEST [7864] FATAL:  could not load D:/Programme/PostgreSQL/16/data/pg_hba.conf
2023-10-17 16:32:03.162 CEST [15460] FATAL:  Password-Authentification for user »test« failed
2023-10-17 16:32:03.162 CEST [15460] DETAIL:  user »test« does not have a valid SCRAM-secret.
    connection corresponded with file »D:/Programme/PostgreSQL/16/data/pg_hba.conf« line 117: »host    all             all             ::1/128                 scram-sha-256«
ReimuHakurei commented 12 months ago

When you created the user, what exact command did you use? If you created it using an MD5 password instead of the newer SCRAM setup, you will need to set pg_hba.conf to md5 instead.

twistios commented 12 months ago

I just used the UI in phppgadmin to create the new user/role (maybe this is not the right way to do it). There you can not select the method.

ReimuHakurei commented 12 months ago

Update your pg_hba.conf to allow MD5 and restart Postgres and this will likely resolve your issue.

twistios commented 12 months ago

I was not able to allow both SCRAM and MD5, but if I only allow MD5 it works.