pg用户赋予只读权限

./createuser --interactive iomsx;
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

./psql -p 15432
alter user iomsx with password 'iomsx2_2022022';
alter user iomsx set default_transaction_read_only=on;
grant all on database skylarx2 to ioms;
c skylarx2
grant select on all tables in schema public to ioms;
quit

vi pg_hba.conf
peer 修改成md5
/etc/init.d/postgres/reload

./psql -p 15432 -U ioms -d skylarx2

原文地址:https://www.cnblogs.com/vzhangxk/p/13173168.html