-2

I have PostgreSQL 12 installed and using Windows 10. My goal is to connect to postgre via php, because it didn't work I tried with plsql but it didn't work either, i always get (with both plsql and php using PDO):

FATAL: password authentication failed for user "postgres"

Connection via plsql in cmd

However, when trying via pgAdmin4, I can connect and access my databases. I first use my root password then sometime my postgres user one, so I'm sure my password works.

Here is my pg_hba.conf file: pg_hba.conf file

I have a set password for postgres which was set vua pgAdmin4.

I don't understand why it would work one way and not the other, can anyone help me?

MasterPaw
  • 3
  • 2
  • Try to give another password via pgAdmin4. ALTER USER postgres PASSWORD 'newPassword'; – I S Aug 20 '20 at 09:19
  • @IS is ALTERROLE and ALTER USER the same? I did both anyway and it applied and work for pgAdmin4 but not plsql. Another thing is that when launching pgAdmin with my default navigator (Opera) i can open some DBs but not the one I want (Uknown internal error), whereas with Firefox i can open all – MasterPaw Aug 20 '20 at 09:43
  • Actually I found the issue, I'll post an answer, thanks anyway ! – MasterPaw Aug 20 '20 at 09:52

1 Answers1

0

So after trying several things, I found that plsql and php error was due to the wrong port being adressed.

By default 5432 is used, but for some reason my configuration was using 5433. You can find this information in pgAdmin4 by opening PostgreSQL 12 properties, and then checking in connection tab.

To change the used port in plsql I used:

psql -U postgres -p 5433

Change 5433 by your configured port if you have same issue, you also need to specify the port if using php's PDO.

MasterPaw
  • 3
  • 2