1

EDIT: WINDOWS: Yes Windows. Do not redirect me to answers that specify sudo-ing because, hey, I can't sudo on Windows.

I have just done a fresh install of postgres 11 on Windows and I am getting

C:\Users\J\Documents\Development>psql -U postgres
psql: FATAL:  password authentication failed for user "postgres"
password retrieved from file "C:\Users\J\AppData\Roaming/postgresql/pgpass.conf"

Note that I do not get an opportunity to enter a password - i.e. I do NOT get a password prompt. There is a password in the pgpass.conf file. I am running the cmd.exe box as Administrator.

There is a link to psql in the folder created at installation but that is no good either. It identically does not ask for a password.

Any ideas? Thanks in advance.

JL_SO
  • 1,742
  • 1
  • 25
  • 38
  • Possible duplicate of [Postgresql: password authentication failed for user "postgres"](https://stackoverflow.com/questions/7695962/postgresql-password-authentication-failed-for-user-postgres) and https://stackoverflow.com/q/1471571/62576 and several others. – Ken White Aug 26 '19 at 23:38
  • You will see Ken White that all of those others (at least, all of the ones that I saw) reference non-Windows installations. Any answer that contains instructions to sudo is not applicable here. Hence, my italicization of Windows. – JL_SO Aug 27 '19 at 10:33
  • Ok. Try these instead (all for Windows): https://stackoverflow.com/q/31028623/62576, https://stackoverflow.com/q/47311101/62576, https://stackoverflow.com/q/7086654/62576.. As I said, **and several others**. Searching this site found those within 2 minutes of reading your comment. Add `[windows]` before the error message when searching. – Ken White Aug 27 '19 at 20:48

1 Answers1

3

The password file is documented.

To get a password prompt, locate the file in %APPDATA%\postgresql\pgpass.conf and delete it.

It was probably created automatically by pgAdmin.

If there is an entry in the password file that matches your login, you won't be prompted, and the password is taken from the file. If you delete the file, you will be prompted for a password (if pg_hba.conf is configured accordingly).

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263