Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied for relation

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"

Does anyone have any idea what can be wrong?

like image 323
Bob Avatar asked Mar 20 '13 10:03

Bob


People also ask

How do I fix Postgres permission denied?

Grant privileges to a new user We resolve this permission denied error using the command. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user; The new_user was then able to read data from the table. Similarly, we can also resolve the permission denied error by setting DEFAULT privileges to the user.

How do I connect to a Postgres database?

In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what user name you want to connect as. psql can be told about those parameters via command line options, namely -d, -h, -p, and -U respectively.

How do I check database permissions in PostgreSQL?

Another way to do this is to use the information_schema schema and query the table_privileges table as: $ SELECT * FROM information_schema. table_privileges LIMIT 5; The above query will show detailed information about user privileges on databases as well as tables.


1 Answers

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:

 GRANT ALL PRIVILEGES ON TABLE side_adzone TO jerry; 

This will take care of this issue.

like image 182
Chris Travers Avatar answered Oct 16 '22 10:10

Chris Travers