Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A snippet to quickly create a read-only user for a postgresql DB
CREATE user <username> with encrypted password '<password>';
GRANT CONNECT ON DATABASE <db_name> TO <username>;
GRANT USAGE ON SCHEMA public TO <username>;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <username>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO <username>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment