Question

i have a user created under login roles in pgAdmin. user's name is 'myApp'.

here is the pgsql syntax to create it.

CREATE ROLE myApp LOGIN
  ENCRYPTED PASSWORD 'md58e0b379fc6e92422518682611bcf2d42'
  NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;

all these days i had my application developed by yii framework to connect to database with super user in my end. which is.. user 'postgres'

but after doing a release recently i started getting an error as below

enter image description here

i found its because of i have set permission to the myApp user role for newly created table but have missed to do the same for sequence so i wrote the below script to resolve..

GRANT ALL ON TABLE css_ataps_client_outgoing_call_dates_id_seq TO myAppAdmin;
GRANT SELECT, UPDATE ON TABLE css_ataps_client_outgoing_call_dates_id_seq TO myApp;

now i need to enable my application to connect to database using the same login as my production application which is myApp but not postgres.

but unfortunately it doesn't work unless i use postgres user. The error i got when trying to connect with myApp user is nothing. not even recorded in logs. so i can confirm that login details are same and its working and the issue could be the user myApp doesnt have read / write access to any single table. so i want to check for which table in database it doesnt have permission or vice versa.

please tell me a way to find this out. thanks.

Was it helpful?

Solution

This will do. Try and let me know.

GRANT ALL ON DATABASE <ur database name> TO myApp; <- not this

TRY THIS QUERY..!

GRANT SELECT,UPDATE,INSERT,DELETE ON ALL TABLES IN SCHEMA public TO myApp;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top