pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedWhy password authentication failed for user "postgres"?
5+ messages / 5 participants
[nested] [flat]
* Why password authentication failed for user "postgres"?
@ 2022-06-03 22:32 BeginnerC <chuxuec@outlook.com>
0 siblings, 3 replies; 5+ messages in thread
From: BeginnerC @ 2022-06-03 22:32 UTC (permalink / raw)
To: pgsql-general
Hello everyone,
I am a newbie to the postgres,when I use the psql to connect to the
postgres,a error message printed:
These command list like this:
psql -U postgres
Password for user postgres:postgres
*postgreSQL: password authentication failed for user "postgres"*
*
*
How to solve this problem?
Thanks in advance!
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Why password authentication failed for user "postgres"?
@ 2022-06-03 22:38 Reid Thompson <jreidthompson@nc.rr.com>
parent: BeginnerC <chuxuec@outlook.com>
2 siblings, 0 replies; 5+ messages in thread
From: Reid Thompson @ 2022-06-03 22:38 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Sat, 2022-06-04 at 06:32 +0800, BeginnerC wrote:
> Hello everyone,
> I am a newbie to the postgres,when I use the psql to connect to the
> postgres,a error message printed:
> These command list like this:
>
> psql -U postgres
> Password for user postgres:postgres
> postgreSQL: password authentication failed for user "postgres"
>
> How to solve this problem?
> Thanks in advance!
this may work...
switch user to postgres.
$ sudo su - postgres
login to postgres
$ psql
reset the password for postgres
postgres-# \password
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Why password authentication failed for user "postgres"?
@ 2022-06-04 16:00 Jeff Janes <jeff.janes@gmail.com>
parent: BeginnerC <chuxuec@outlook.com>
2 siblings, 0 replies; 5+ messages in thread
From: Jeff Janes @ 2022-06-04 16:00 UTC (permalink / raw)
To: BeginnerC <chuxuec@outlook.com>; +Cc: pgsql-general
On Fri, Jun 3, 2022 at 6:32 PM BeginnerC <chuxuec@outlook.com> wrote:
> Hello everyone,
> I am a newbie to the postgres,when I use the psql to connect to the
> postgres,a error message printed:
> These command list like this:
>
> psql -U postgres
> Password for user postgres:postgres
> *postgreSQL: password authentication failed for user "postgres"*
>
> How to solve this problem?
> Thanks in advance!
>
The password you type should not be showing up as you type it, which is
what you appear to be showing above. Also, 'postgres' is a horrible
password, you might as well configure 'trust' authentication if you are
going to use that as a password.
Look in the db server's log file for a (possibly) more detailed error
message.
Cheers,
Jeff
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Why password authentication failed for user "postgres"?
@ 2022-06-05 23:06 Frank Finner <postgresql@finner.de>
parent: BeginnerC <chuxuec@outlook.com>
2 siblings, 1 reply; 5+ messages in thread
From: Frank Finner @ 2022-06-05 23:06 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2022-06-04 00:32, BeginnerC wrote:
> Hello everyone,
> I am a newbie to the postgres,when I use the psql to connect to the
> postgres,a error message printed:
> These command list like this:
>
> psql -U postgres
> Password for user postgres:postgres
> *postgreSQL: password authentication failed for user "postgres"*
> *
> *
> How to solve this problem?
> Thanks in advance!
* Which OS are you working on?
* Can you show us your pg_hba.conf?
If you use -U with psql, the connection must not try to use method
"peer" (which means "use the system user with this name", but also means
"You must be logged in with the system user corresponding to the
postgresql user"), but some kind of authorization, like md5, and use it
with IP address. This might be difficult for the user postgres, who
often has no password set in the database. If you really need to connect
with user postgres and some password, you can set one using the method
described by Reid Thompson.
Regards,
Frank
Attachments:
OpenPGP_0xE5418B2366C33EE6.asc (application/pgp-keys, 627B) download
OpenPGP_signature (application/pgp-signature, 235B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Why password authentication failed for user "postgres"?
@ 2022-06-05 23:29 David G. Johnston <david.g.johnston@gmail.com>
parent: Frank Finner <postgresql@finner.de>
0 siblings, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2022-06-05 23:29 UTC (permalink / raw)
To: Frank Finner <postgresql@finner.de>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Sun, Jun 5, 2022 at 4:06 PM Frank Finner <postgresql@finner.de> wrote:
> If you use -U with psql, the connection must not try to use method "peer"
> (which means "use the system user with this name", but also means "You must
> be logged in with the system user corresponding to the postgresql user"),
> but some kind of authorization, like md5, and use it with IP address.
>
This is simply wrong (though I suppose only in a corner case). You must
connect via socket but peer authentication can still work. In particular,
so long as the value specified for "-U" is your operating system user name
the connection will work just the same as if you didn't specify -U at all
and instead relied on the psql default behavior of using your operating
system user name for the value of user. In short, the server only knows
what value "user" has as part of the connection string - it has no
knowledge of how that value became set. However, it can prove that the
socket connection being requested is owned by a particular user.
I think (going from memory at the moment) you can get the main exception to
this rule via usage of pg_ident.conf (i.e., be logged in as "osuser" and
supply "-U postgres"; peer auth will work so long as osuser is mapped to
postgres and you connect via the socket (i.e., local, not host).
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2022-06-05 23:29 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 22:32 Why password authentication failed for user "postgres"? BeginnerC <chuxuec@outlook.com>
2022-06-03 22:38 ` Reid Thompson <jreidthompson@nc.rr.com>
2022-06-04 16:00 ` Jeff Janes <jeff.janes@gmail.com>
2022-06-05 23:06 ` Frank Finner <postgresql@finner.de>
2022-06-05 23:29 ` David G. Johnston <david.g.johnston@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox