Last active
July 7, 2017 00:00
-
-
Save tfentonz/566964351b3bee76e4abc1b3aad183df to your computer and use it in GitHub Desktop.
PostgreSQL read only user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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