postgresql icon indicating copy to clipboard operation
postgresql copied to clipboard

PostgreSQL 16 : Unable to create the XXXXXXXX table (permission denied for schema public

Open pulse-mind opened this issue 11 months ago • 1 comments

It looks like we need to add a right: https://medium.com/@dmitry.romanoff/postgresql-version-15-error-permission-denied-for-schema-public-dc8285c41e00

PostgreSQL version 15+ will error out and tell you that you don’t have permission to create something inside the public schema without explicitly specifying who is allowed to do that beforehand. It is now necessary to grant permissions to a user explicitly.

What should be changed?

If it’s Postgres version 15+ right after the DB has been created and the DB user has been created, and before any objects creation, connect to the as user admin and run this:

GRANT ALL ON SCHEMA public TO <DB_user>;

pulse-mind avatar Feb 26 '24 17:02 pulse-mind

After few tests, I did : psql -d mydatabase I was logged as postgres grant create on schema public to mydatabase

And it works

pulse-mind avatar Feb 26 '24 18:02 pulse-mind

This was a change introduced in PostgreSQL v15, so not something we can actually fix. It was deliberately tightened to encourage people to not use the public schema. Ideally you should create a schema for your application, and use that instead:

https://www.crunchydata.com/blog/be-ready-public-schema-changes-in-postgres-15

gclough avatar Mar 14 '24 10:03 gclough

Thank you for your time and your answer.

pulse-mind avatar Mar 14 '24 11:03 pulse-mind