Thread: Password forgotten

Password forgotten

From
Arbol One
Date:

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?

Thanks in advance.


--
ArbolOne.ca Using Fire Fox and Thunderbird. ArbolOne is composed of students and volunteers dedicated to providing free services to charitable organizations. ArbolOne on Java Development is in progress [ í ]

Re: Password forgotten

From
Hans Schou
Date:

Have you tried

   sudo -u postgres psql


On Tue, Apr 23, 2024 at 2:14 PM Arbol One <ArbolOne@hotmail.ca> 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?

Thanks in advance.


--
ArbolOne.ca Using Fire Fox and Thunderbird. ArbolOne is composed of students and volunteers dedicated to providing free services to charitable organizations. ArbolOne on Java Development is in progress [ í ]


--
𝕳𝖆𝖓𝖘 𝕾𝖈𝖍𝖔𝖚
☏ ➁➁ ➅➃ ➇⓪ ➁⓪

Re: Password forgotten

From
"David G. Johnston"
Date:


On Tuesday, April 23, 2024, Arbol One <ArbolOne@hotmail.ca> 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.

Re: Password forgotten

From
Tom Lane
Date:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tuesday, April 23, 2024, Arbol One <ArbolOne@hotmail.ca> wrote:
>> psql-16 asks for the password, which I have forgotten.
>> 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.

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



Re: Password forgotten

From
hubert depesz lubaczewski
Date:
On Tue, Apr 23, 2024 at 08:14:15AM -0400, Arbol One wrote:
> Hello.
> In my Debian box, after entering this command to psql-16, *psql -h localhost
> -U postgres*

You might want to read
https://www.depesz.com/2008/11/28/recovering-lost-postgresql-password/

Best regards,

depesz