Skip to content

Instantly share code, notes, and snippets.

@mr-linch
Last active February 6, 2021 19:42
Show Gist options
  • Save mr-linch/8c087ddf50ecaadd19a878940b372014 to your computer and use it in GitHub Desktop.
Save mr-linch/8c087ddf50ecaadd19a878940b372014 to your computer and use it in GitHub Desktop.
πŸ‘β€πŸ—¨ PostgreSQL: Create readonly user
-- create user (e.g. metabase)
create user metabase with encrypted password 'password';
-- allow user connect to db
grant connect on database site to metabase;
-- allow user access to schema
grant usage on schema public to metabase;
-- grant select on existing tables
grant select on all tables in schema public to metabase;
-- allow user to access all tables in schema
alter default privileges in schema public
grant select on tables to metabase;
-- limit number of connections
-- alter role metabase with connection limit 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment