Last active
April 18, 2024 07:26
-
-
Save nherment/707fdb556b1b6aaaf2da5391b15215e5 to your computer and use it in GitHub Desktop.
Postgresql user setup
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
-- As postgres user: | |
CREATE DATABASE <DB_NAME>; | |
CREATE USER <USERNAME> WITH LOGIN ENCRYPTED PASSWORD '<PASSWORD>'; | |
GRANT ALL PRIVILEGES ON DATABASE <DB_NAME> TO <USERNAME>; | |
ALTER DATABASE <DB_NAME> OWNER TO <USERNAME>; | |
-- grant read-only | |
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