ANXS / postgresql

Fairly full featured Ansible role for Postgresql.
http://anxs.io/
MIT License
848 stars 571 forks source link

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

Closed pulse-mind closed 3 months ago

pulse-mind commented 4 months ago

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 commented 4 months ago

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

And it works

gclough commented 3 months ago

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

pulse-mind commented 3 months ago

Thank you for your time and your answer.