Skip to content

Instantly share code, notes, and snippets.

@tfentonz
Last active July 7, 2017 00:00
Show Gist options
  • Save tfentonz/566964351b3bee76e4abc1b3aad183df to your computer and use it in GitHub Desktop.
Save tfentonz/566964351b3bee76e4abc1b3aad183df to your computer and use it in GitHub Desktop.
PostgreSQL read only user
psql <database>
CREATE USER <user> WITH PASSWORD '<password>' VALID UNTIL 'infinity';
GRANT CONNECT ON DATABASE <database> TO <user>;
GRANT USAGE ON SCHEMA public TO <user>;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO <user>;
GRANT SELECT ON ALL TABLES IN SCHEMA public to <user>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO <user>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment