pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
postgres (superuser) cannot connect to database
3+ messages / 3 participants
[nested] [flat]

* postgres (superuser) cannot connect to database
@ 2022-11-23 12:41 Holger Jakobs <holger@jakobs.com>
  2022-11-23 14:14 ` Re: postgres (superuser) cannot connect to database Laurenz Albe <laurenz.albe@cybertec.at>
  2022-11-23 14:18 ` Re: postgres (superuser) cannot connect to database Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: Holger Jakobs @ 2022-11-23 12:41 UTC (permalink / raw)
  To: pgsql-admin@lists.postgresql.org

How come a user who has issued "set role to postgres", so that the 
current user is postgres, cannot connect to a database?

Are superuser rights not sufficient?

student@[local]:5434//~:=# \c einkauf
Verbindung zum Server auf Socket »/var/run/postgresql/.s.PGSQL.5434« 
fehlgeschlagen: FATAL:  keine Berechtigung für Datenbank »einkauf«
DETAIL:  Benutzer hat das CONNECT-Privileg nicht.
Vorherige Verbindung wurde behalten
student@[local]:5434//~:=# grant connect on database einkauf to postgres;
GRANT
student@[local]:5434//~:=# \c einkauf
Sie sind jetzt verbunden mit der Datenbank »einkauf« als Benutzer »student«.
student@[local]:5434//einkauf:=>

Who can explain this? It's version 15 I'm using for the first time, 
haven't checked with oder versions.

Best Regards,

Holger


-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012



Attachments:

  [application/pgp-signature] OpenPGP_signature (202B, ../../82e7c3a1-7ab8-0b2e-910e-26946f27dde6@jakobs.com/2-OpenPGP_signature)
  download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: postgres (superuser) cannot connect to database
  2022-11-23 12:41 postgres (superuser) cannot connect to database Holger Jakobs <holger@jakobs.com>
@ 2022-11-23 14:14 ` Laurenz Albe <laurenz.albe@cybertec.at>
  1 sibling, 0 replies; 3+ messages in thread

From: Laurenz Albe @ 2022-11-23 14:14 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; pgsql-admin@lists.postgresql.org

On Wed, 2022-11-23 at 13:41 +0100, Holger Jakobs wrote:
> How come a user who has issued "set role to postgres", so that the 
> current user is postgres, cannot connect to a database?
> 
> Are superuser rights not sufficient?
> 
> student@[local]:5434//~:=# \c einkauf
> Verbindung zum Server auf Socket »/var/run/postgresql/.s.PGSQL.5434« 
> fehlgeschlagen: FATAL:  keine Berechtigung für Datenbank »einkauf«
> DETAIL:  Benutzer hat das CONNECT-Privileg nicht.
> Vorherige Verbindung wurde behalten
> student@[local]:5434//~:=# grant connect on database einkauf to postgres;
> GRANT
> student@[local]:5434//~:=# \c einkauf
> Sie sind jetzt verbunden mit der Datenbank »einkauf« als Benutzer »student«.
> student@[local]:5434//einkauf:=>
> 
> Who can explain this? It's version 15 I'm using for the first time, 
> haven't checked with oder versions.

PostgreSQL doesn't use the current role for the new connection, but the
role you used to authenticate originally.

See \conninfo or "SELECT session_user;" to see that role.

Yours,
Laurenz Albe





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: postgres (superuser) cannot connect to database
  2022-11-23 12:41 postgres (superuser) cannot connect to database Holger Jakobs <holger@jakobs.com>
@ 2022-11-23 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2022-11-23 14:18 UTC (permalink / raw)
  To: Holger Jakobs <holger@jakobs.com>; +Cc: pgsql-admin@lists.postgresql.org

Holger Jakobs <holger@jakobs.com> writes:
> How come a user who has issued "set role to postgres", so that the 
> current user is postgres, cannot connect to a database?

\c makes a fresh connection to the server.  SET ROLE in your old
session will not carry over to that (nor any other session state).

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-11-23 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 12:41 postgres (superuser) cannot connect to database Holger Jakobs <holger@jakobs.com>
2022-11-23 14:14 ` Laurenz Albe <laurenz.albe@cybertec.at>
2022-11-23 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>

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