Created
May 28, 2019 14:52
-
-
Save olance/48f216ea16ab134521f8a596973bb953 to your computer and use it in GitHub Desktop.
A snippet to quickly create a read-only user for a postgresql DB
This file contains 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
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