Subject: Re: Password forgotten

From: "David G. Johnston" <[email-masked]>
Date: Tue, 23 Apr 2024 06:27:00 -0700

On Tuesday, April 23, 2024, Arbol One <[email-masked]> wrote:

> Hello.
> In my Debian box, after entering this command to psql-16, *psql -h
> localhost -U postgres*
>
> psql-16 asks for the password, which I have forgotten.
> So I get this message:
>
>
>
> *psql: error: connection to server at "localhost" (::1), port 5432 failed:
> FATAL:  password authentication failed for user "postgres" connection to
> server at "localhost" (::1), port 5432 failed: FATAL:  password
> authentication failed for user "postgres" *
>
> Is there a way I can retrieve this master password?
>

Nope.  You need to login using a method that doesn’t require a password
then change the password.  See pg_hba.conf for authentication options.
Usually connecting via local and peer authentication is the default option.

David J.

---

From: Tom Lane <[email-masked]>
Date: Tue, 23 Apr 2024 10:19:17 -0400

> Usually connecting via local and peer authentication is the default option.

If all else fails, shut the server down and start it in single-user
mode.  That will let you in as a superuser and you can use ALTER USER
to reset the role's password.

			regards, tom lane