I have a user that I need to allow SELECT
access to a database. I've followed all the instructions I've found scattered all over SO and I can't get anything to work.
I've tried all the suggested solutions to all of the following links:
How do you create a read-only user in PostgreSQL?
ERROR: permission denied for relation tablename on Postgres while trying a SELECT as a readonly user
Permission denied for relation
...and many more references to the PSQL docs, blogs and user groups. Nothing is working.
Here are the commands I recently used as the postgres user to grant privileges:
postgres@dev:~$ psql
psql (9.1.9)
Type "help" for help.
postgres=# grant usage on SCHEMA public to proton_read;
GRANT
postgres=# grant select on all tables in schema public to proton_read;
GRANT
postgres=# alter default privileges in schema public grant select on tables to proton_read;
ALTER DEFAULT PRIVILEGES
Here are the commands used as the read only user:
proton_read@dev:~$ psql proton
psql (9.1.9)
Type "help" for help.
proton=> select * from leads_lead limit 1;
ERROR: permission denied for relation leads_lead
Here's the kicker, I had this working once. I have a sample database dump that I'm using to teach basic SQL to business co-workers. We are covering simple commands such as SELECT
, ORDER BY
, LIMIT
and JOIN
. I had an old dump and was able to grant read only access. I dropped the database and did a pg_restore with a newer version of the database and now I cannot re-grant the SELECT access.
Any help would be greatly appreciated.