Created
February 23, 2018 06:45
-
-
Save okanmenevseoglu/a0321f52f5baeff15e1d7d063e0789af to your computer and use it in GitHub Desktop.
Creating User and Giving Granular Access to the User on 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 new user to the DB | |
CREATE USER {{username}} WITH ENCRYPTED PASSWORD {{password}}; | |
-- Give access connection to the wanted DB | |
GRANT CONNECT ON DATABASE {{dbname}} TO {{username}}; | |
-- Give access to the wanted schema | |
GRANT USAGE ON SCHEMA {{schemaname}} TO {{userName}}; | |
-- Give select access to the sequences for the wanted schema | |
GRANT SELECT ON ALL SEQUENCES IN SCHEMA {{schemaName}} TO {{userName}}; | |
-- Give select access to the all tables for the wanted schema | |
GRANT SELECT ON ALL TABLES IN SCHEMA {{schemaName}} TO {{userName}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment