33

I couldn't find the answer in the docs, what exactly is a superuser in postgres?

Does the superuser have all privileges? Is it per database? Per instance?

3 Answers 3

22

https://www.postgresql.org/docs/current/static/sql-createrole.html

These clauses determine whether the new role is a "superuser", who can override all access restrictions within the database.

yes - all privileges in all databases on the specified cluster

Sign up to request clarification or add additional context in comments.

1 Comment

A superuser bypasses all permission checks and is able to do some things that no other user may do, like add C functions or shell out to the OS and run arbitrary shell commands using the OS user ID that runs the database service. It is far more dangerous than just having all privileges in all databases. See the answer by @laurenz-albe
7

A superuser in PostgreSQL is a user who bypasses all permission checks.

Superusers can run commands that can destabilize or crash the database server (e.g., create C functions) and access the operating system.

Comments

-5

Superuser is per database. From manual:

SUPERUSER NOSUPERUSER These clauses determine whether the new role is a "superuser", who can override all access restrictions within the database. Superuser status is dangerous and should be used only when really needed. You must yourself be a superuser to create a new superuser. If not specified, NOSUPERUSER is the default.

The superuser role bypasses all permission checks.

The term "cluster" in PostgreSQL is a historical and it is un-related to the PostgreSQL command CLUSTER, which is about organizing tables - you set user per-database, not per-cluster. A cluster is created when PostgreSQL is installed. The installation will usually do initdb - it will create a new cluster with one database in for you. Cluster is just data dir with databases inside. For location of that data dir look into manual.

1 Comment

No. The term "database" is often used colloquially for "database cluster." Moreover the term "cluster" is still very much in use and is not merely historical, regardless of whether it seems confusing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.