–创建readonly用户
create user mes2read with password ‘read@2024’;
–设置用户默认事务只读
alter user mes2read set default_transaction_read_only = on;
–赋予用户连接数据库权限
grant connect on database postgres to mes2read;
–赋予schema,序列,表查看权限
grant usage on schema public to mes2read;
grant select on all sequences in schema public to mes2read;
grant select on all tables in schema public to mes2read;
–设置未来新增表的查看权限
alter default privileges in schema public grant select on tables to mes2read;