Under postgres user:
postgres=# GRANT ALL ON schema public TO trololo;
GRANT
postgres=# \dn+
List of schemas
Name | Owner | Access privileges | Description
--------+-------------------+----------------------------------------+------------------------
public | pg_database_owner | pg_database_owner=UC/pg_database_owner+| standard public schema
| | =U/pg_database_owner +|
| | trololo=UC/pg_database_owner |
(1 row)
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+------------------------
marketing | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =Tc/postgres +
| | | | | | | postgres=CTc/postgres +
| | | | | | | marketing=CTc/postgres
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
trololo | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =Tc/postgres +
| | | | | | | postgres=CTc/postgres +
| | | | | | | trololo=CTc/postgres
Under trololo user:
michael@michael:~$ psql -U trololo
Password for user trololo:
psql (15.2 (Ubuntu 15.2-1.pgdg20.04+1))
Type "help" for help.
trololo=> create table trololo_entity (id int8 not null, trololo varchar(255), primary key (id));
ERROR: permission denied for schema public
LINE 1: create table trololo_entity (id int8 not null, trololo varch...
^
trololo=>
I want to find out the following:
- Why do I still get the error message if I have granted the privileges?
- I faced this problem after upgrading PostgreSQL from 12 to 15. If I'm not mistaken, for 12th there was no need to grant privileges on schema public. I just granted privileges on the table and that's all. Why should I grant permissions on this schema as well as on the table?