postgresql-只读账号授权

2021/8/11 19:06:24

本文主要是介绍postgresql-只读账号授权,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.. 只读账号授权

# 超级用户登录数据库
create user ro_user password 'readonly';

# 设置Postgres数据库为只读的transaction
alter user ro_user set default_transaction_read_only=on;

# 赋予用户权限,查看public模式下所有表:(新建表也会有只读权限)
grant usage on schema public to ro_user;
alter default privileges in schema public grant select on tables to ro_user;

# 赋予用户连接数据库权限
grant connect on database zhong to ro_user;
# 切换到指定数据库
\c zhong
# 赋予用户表、序列查看权限
grant usage on schema public to ro_user;
grant select on all sequences in schema public to ro_user;
grant select on all tables in schema public to ro_user;
————————————————
https://blog.csdn.net/weixin_38623994/article/details/106651022

 



这篇关于postgresql-只读账号授权的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程