postgresql 设置只读用户

postgresql 设置只读用户

`
CREATE USER readonly WITH ENCRYPTED PASSWORD ‘ropass’;
alter user readonly set default_transaction_read_only=on;
GRANT USAGE ON SCHEMA public to readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly;

— repeat code below for each database:

GRANT CONNECT ON DATABASE foo to readonly;
\c foo
GRANT USAGE ON SCHEMA public to readonly;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

`

    原文作者:PostgreSQL
    原文地址: https://www.cnblogs.com/cutd/p/6259072.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞