I’m following ODSC’s SQL repo and I came across the error below when trying to connect to a server in PgAdmin 4:
When Googling a solution, one common problem is that the path isn’t set up properly (I’m using Windows). So I added the following to the Systems Variables:
C:\Program Files\PostgreSQL\15\bin C:\Program Files\PostgreSQL\15\lib
But that didn’t solve my problem.
So next, I thought I that I might’ve fatfingered the password. So my next step was to figure out how to reset the password for the postgres user.
I ended up going to C:\Program Files\PostgreSQL\15\data\pg_hba.conf to modify the pg_hba.conf file using VSCode.
Within that file, I changed the authentication method to “trust”.
Then I restarted PostgreSQL server using Windows’s Services app.
Next, I ran the Command Prompt and typed in the following:
psql -U postgres
This ran PostgreSQL and create a new user (the -u stands for “user,” so we have a user called “postgres”). From here, you should be prompted to enter a password, and then you’ll be prompted to retype the password.
Next, I went back to the pg_hba.conf file and changed “trust” back to “scram-sha-256.”
And finally, I went back to PgAdmin 4 to connect to the server and it worked!