I tried to run simple sql command:
select * from site_adzone;
and I got this error
ERROR: permission denied for relation site_adzone
What could be the problem here?
I tried also to do select for other tables and got same issue. I also tried to do this:
GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
but I got this response from console
WARNING: no privileges were granted for "jerry"
Do you have some idea what can be wrong?
GRANT on the database is not what you need. Grant on the tables directly.
Granting privileges on the database mostly is used to grant or revoke connect privileges. This allows you to specify who may do stuff in the database if they have sufficient other permissions.
You want instead:
This will take care of this issue.
Connect to the right database first, then run:
To grant permissions to all of the existing tables in the schema use:
To specify default permissions that will be applied to future tables use:
e.g.
If you use
SERIAL
orBIGSERIAL
columns then you will probably want to do the same forSEQUENCES
, or else yourINSERT
will fail (Postgres 10'sIDENTITY
doesn't suffer from that problem, and is recommended over theSERIAL
types), i.e.See also my answer to PostgreSQL Permissions for Web App for more details and a reusable script.
Ref:
GRANT
ALTER DEFAULT PRIVILEGES
Posting Ron E answer for grant privileges on all tables as it might be useful to others.
1st and important step is connect to your db:
2 step, grant privileges