postgresql
postgresql copied to clipboard
PostgreSQL 16 : Unable to create the XXXXXXXX table (permission denied for schema public
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>;
After few tests, I did :
psql -d mydatabase
I was logged as postgres
grant create on schema public to mydatabase
And it works
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
Thank you for your time and your answer.