暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片
openGauss 用户权限统计及权限回收.docx
141
8页
2次
2025-03-10
5墨值下载
openGauss
用户权限统计及权限回收
一、环境配置
主机名
centos-1
IP 192.168.1.11
操作系统
CentOS Linux release 7.6.1810 (Core)
数据库版本
openGauss 6.0.1 build 84c20a90
二、用户权限统计
(
解析
acl
权限方式
)
本案例为在
postgres
库中创建用户,然后创建
testdb
数据库,后续
testdb
库中
创建用户对象并进行相关授权操作。
创建用户
testuser:
\c postgres
create user testuser with password 'Test1234';
创建数据库
testdb
create database testdb;
\c testdb;
1
database
权限
授予
testuser
访问
testdb
库以及在
testdb
库创建新
schema
的权限
grant connect,create on database testdb to testuser;
查询
testuser
database
权限
with t as (select datname,
(aclexplode(datacl)).grantee,
(aclexplode(datacl)).privilege_type
from pg_database)
select t.datname,ro.rolname,t.privilege_type,
'revoke '||t.privilege_type||' on database '||t.datname||' from '||ro.rolname||';' as revoke_sql
from t
inner join pg_roles ro on ro.oid=t.grantee
where ro.rolname='testuser';
2
schema
权限
创建
schema1
create schema schema1;
授予
testuser
schema1
模式创建对象的权限
grant create,usage on schema schema1 to testuser;
查询
testuser
schema
权限
with t as (select nspname "schema",
(aclexplode(nspacl)).grantee,
(aclexplode(nspacl)).privilege_type
from pg_namespace)
select t.schema,ro.rolname,t.privilege_type,
'revoke '||t.privilege_type||' on schema '||t.schema||' from '||ro.rolname||';' as revoke_sql
from t
inner join pg_roles ro on ro.oid=t.grantee
where ro.rolname='testuser';
3
table
权限
创建
public.t1
create table public.t1 (id int);
授予
testuser
public.t1
的增删改查权限
grant select,insert,update,delete on table public.t1 to testuser;
查询
testuser
table
权限
with t as (
select na.nspname "schema",cl.relname,
(aclexplode(relacl)).grantee,
(aclexplode(relacl)).privilege_type
from pg_class cl
inner join pg_namespace na on na.oid=cl.relnamespace
where cl.relkind in ('r','f'))
select t.schema,t.relname,ro.rolname,t.privilege_type,
'revoke '||t.privilege_type||' on table '||t.schema||'.'||t.relname||' from '||ro.rolname||';' as revoke_sql
from t
inner join pg_roles ro on ro.oid=t.grantee
where ro.rolname='testuser';
4
table column
权限
of 8
5墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜