Created
March 30, 2017 12:06
-
-
Save kerma/91d5584ad8871f8e4c7753bdb95573d2 to your computer and use it in GitHub Desktop.
PostgreSQL user management
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
-- Add a user with readonly privileges to db | |
CREATE USER username WITH PASSWORD '<password>'; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO username; | |
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO username; | |
-- Delete a user | |
revoke all privileges on all tables in schema public from username; | |
drop user username; | |
-- Add a "root" user to database | |
GRANT ALL PRIVILEGES ON DATABASE database_name TO root; | |
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO root; | |
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO root; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment