2
votes

After I install Postgres 12 on my windows machine and try to log in in the command line using: psql

I am prompted for a password. I enter the password that I used during the install, but it is rejected by Postgres with the message:

psql: error: could not connect to server: FATAL: password authentication failed for user "username"

username is actually my windows username.

I have tried:

  • uninstalling Postgres with and without deleting the Postgres folder, and then doing a fresh re-install.
  • editing the pg_hba file and putting "trust" at the end of every line
  • using the windows password

Nothing works. Please help.

1
The password you gave is likely for the postgres user. Try specifying the username when you connect. - Jeremy

1 Answers

3
votes

The password you entered during installation is for the postgres database user, the superuser that was created with the database cluster.

But the default value for the database user name when you run psql is the same as the operating system user.

So unless you are logged in as the postgres operating system user, you have to specify the username explicitly:

psql -U postgres