Skip to content

Instantly share code, notes, and snippets.

@varaprasadh
Created November 14, 2024 09:10
Show Gist options
  • Save varaprasadh/5fe6c21013f90b9c08d72eb712a514a9 to your computer and use it in GitHub Desktop.
Save varaprasadh/5fe6c21013f90b9c08d72eb712a514a9 to your computer and use it in GitHub Desktop.
Create a postgres user / role
  • create role
create role 'fleet-support-readonly';
  • set password
ALTER USER user_name WITH PASSWORD 'new_password';
  • grant login permission
 ALTER ROLE "fleet-support-readonly" WITH LOGIN; 
  • switch to a database
\c <db_name>
  • grant connect on a database
GRANT CONNECT ON DATABASE "stackenable-production" TO "fleet-support-readonly";
  • grant readonly permission
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "fleet-support-readonly";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment