阿里云rds postgres回收用户权限

  • 时间:
  • 浏览:1
  • 来源:大发彩神8官网—大发彩神8快3

注1

单单回收某个用户的create权限是这麼用的,需要回收public的create权限,

hc_dba=> revoke create on schema public from xhc_rw;

REVOKe

xhc_dba=> c - xhc_rw;

You are now connected to database "xhc_dba" as user "xhc_rw".

xhc_dba=> create t000(id bigint,id2 serial primary key);

xhc_dba=> create table t000(id bigint,id2 serial primary key);

CREATE TABLE

xhc_dba=>

xhc_dba=> alter table t11 owner to xhc_test;

ALTER TABLE

xhc_dba=> alter table t11 owner to xhc_rw;

ERROR: permission denied for schema public

将会回收了所有用户的create权限,很多很多 表的所属权是不可逆的,这麼 属于xhc_rw的表改成xhc_test也不 就非要再改回来了

而public 默认owner是初始化实列的用户,很多很多 提供单将public owner改成自己建的用户

将test,template1数据库public schema的owner给xhc_test 。

=> dn

List of schemas

注3

hc_dba=> c

psql (9.5.2, server 9.4.10)

You are now connected to database "xhc_dba" as user "xhc_test".

xhc_dba=> dn

List of schemas

grant select,insert,update,delete on all tables in schema public to xhc_rw;

WARNING: no privileges were granted for “test” —将会test表这麼 就属于xhc_rw用户,很多很多 会有警告,将会把test 表owner改成xhc_test就我不要 有警告了

xhc_dba=> grant select,usage on all sequences in schema public to xhc_rw;

GRANT

xhc_dba=> alter default privileges in schema public grant select,update,delete,insert on tables to xhc_rw;

ALTER DEFAULT PRIVILEGES

xhc_dba=> alter default privileges in schema public grant select,usage on sequences to xhc_rw;

ALTER DEFAULT PRIVILEGES

注2

xhc_dba=> c

psql (9.5.2, server 9.4.10)

You are now connected to database "xhc_dba" as user "xhc_rw".

xhc_dba=> d

xhc_dba=> d

要想也不 xhc_rw对不属于自己的表一定会读写权限需要执行以下4句

2,若为rds_superuser 则改为nords_superuser

xhc_dba=> alter user xhc_rw nords_superuser;

1,提工单

将会当初设计一定会用的public schema,而public schema对所有用户权限这麼限制,很多很多 需要回收要素用户的建表权限,

=> dn

List of schemas

3,回收create 权限

xhc_dba=> revoke create on schema public from public;

xhc_dba=> c - xhc_rw;

You are now connected to database "xhc_dba" as user "xhc_rw”. —回收成功

xhc_dba=> create table t000(id serial,id2 bigint);

ERROR: permission denied for schema public

xhc_dba=>

xhc_dba=> drop table t000;

人太好回收了xhc_rw的create权限,也不xhc_rw对也不 建的表还是有ddl,权限的