Password forgotten

Started by Arbol Onealmost 2 years ago5 messagesgeneral
Jump to latest
#1Arbol One
ArbolOne@hotmail.ca

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 [ í ]

#2Hans Schou
hans.schou@gmail.com
In reply to: Arbol One (#1)
Re: Password forgotten

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 [ í ]

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

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Arbol One (#1)
Re: Password forgotten

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.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#3)
Re: Password forgotten

"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

In reply to: Arbol One (#1)
Re: Password forgotten

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