Granted all privileges on my PostGres table, but still am getting a "Permission denied" error when attempting to insert/select

Your first command give you the ability to list table (you can just know that there are existing)

GRANT USAGE ON SCHEMA public TO myapp

Then you have to grant SELECT, INSERT, etc... to all the tables in the schema public

GRANT SELECT, UPDATE, INSERT, DELETE ON ALL TABLES IN SCHEMA public TO myapp

I recommand not giving all privileges to a specific app.

If you have sequences :

 GRANT SELECT, UPDATE, USAGE ON ALL SEQUENCES IN SCHEMA public to myapp

If you have functions :

GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO myapp

Then your example will work.

But you still have to apply some command if you want futur created table to be able to be accessed :

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE, INSERT, DELETE, TRIGGER ON TABLES TO myapp

Postgresql have a very weird mecanism it took me a while to understand it !


You're granting permissions in the postgres database instead of the myapp database.

Change the first PSQL command to

psql -Upostgres myapp

And then issue the grants


At first you have to login your new database using postgres user

psql your_db_name -U postgres -h your_host_name

give the ability to list table

GRANT USAGE ON SCHEMA public TO your_user_name

Then you have to grant permission to all the tables in the schema public

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO your_user_name

If you have sequences then give permission

GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO your_user_name