ERROR: permission denied for schema public

Hi,

I have postgresql 16

i have postgres user and i have create one user user1 using command
CREATE USER user WITH PASSWORD password

and created database db using bellow command
CREATE DATABASE db

i have set the privileges using below command
GRANT ALL PRIVILEGES ON DATABASE dbname TO dbuser_name

and then i have login terminal using below command
psql -U user -d db

when i try to create table in that login user i get error

CREATE TABLE table_name (
    name VARCHAR(100)
);

Error:
ERROR: permission denied for schema public
LINE 1: CREATE TABLE table_name (

How i can solve this

please read PostgreSQL ERROR: permission denied for schema public

And, this is a german speaking forum - können wir auf deutsch wechseln?

Andreas

Hi,

security=> c security postgres
You are now connected to database ‘security’ as user ‘postgres’.
security=# GRANT ALL ON SCHEMA public TO demo;
GRANT

In provided link i have checked.

To create table in database I need to grant permission on public schema

As I need to login superuser with that database which I want to allow permission?

Is there any other way like when I assign privileges to user on that database to get public sechma permission also.

Thanks & Regards

Du könntest den DB User gleich als Owner der Datenbank definieren, damit bekommt er auch sofort die Privilegien für das PUBLIC Schema:

CREATE USER dbuser_name WITH PASSWORD 'password';
CREATE DATABASE db owner dbuser_name;
1 „Gefällt mir“

Dieses Thema wurde automatisch 60 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.