Reputation: 3843
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:
Upvotes: 1
Views: 1615
Reputation: 246268
You changed the permissions in database postgres
, but you are trying to create the table in database trololo
(look at the psql
prompt). Since you didn't grant the permissions in database trololo
the attempt to create the table fails.
You are probably misled by psql
's defaults: if you don't specify the database explicitly, for example with the -d
option, psql
will connect to the database with the same name as the database user.
Upvotes: 2