Created
April 26, 2017 08:17
-
-
Save mehmetboraezer/9231665afd84c013b17dcc9f75bb3e4d to your computer and use it in GitHub Desktop.
Create read-only user for postgresql
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 ROLE 'new_username' WITH LOGIN PASSWORD 'new_password' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION VALID UNTIL 'infinity'; | |
GRANT CONNECT ON DATABASE 'db_name' TO 'new_username'; | |
GRANT USAGE ON SCHEMA public TO 'new_username'; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO 'new_username'; | |
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO 'new_username'; | |
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO 'new_username'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment