Skip to content

Instantly share code, notes, and snippets.

@pedroagabreu
Last active January 18, 2016 20:58
Show Gist options
  • Save pedroagabreu/85e11f83572ccab9dea1 to your computer and use it in GitHub Desktop.
Save pedroagabreu/85e11f83572ccab9dea1 to your computer and use it in GitHub Desktop.
Create read-only user/role in Postgres.
# create user
create role myuser login password 'somepassword';
grant connect on database events to myuser;
grant usage on schema public to myuser;
# privs on current stuff
grant select on all tables in schema public to myuser;
grant select on all sequences in schema public to myuser;
grant execute on all functions in schema public to myuser;
# privs on future stuff
alter default privileges in schema public grant select on tables to myuser;
alter default privileges in schema public grant select on sequences to myuser;
alter default privileges in schema public grant execute on functions to myuser;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment