暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss每日一练第 4天

原创 hehe 2021-12-08
422

#opengauss学习的第四天

创建角色role1为系统管理员, role2指定生效日期, role3具有LOGIN属性
omm=# create role role1 sysadmin encrypted password ‘r^123.comCOM’;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

omm=# create role role2 valid begin ‘2022-01-01 00:00:00’ password ‘r^123.comCOM’;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# create role role3 login password ‘r^123.comCOM’;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.

重命名role1
omm=# alter role role1 rename to reole1111;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE

修改role2密码
alter role role2 ENCRYPTED password ‘Abc123.com’;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE

将omm权限授权给role3,再回收role3的权限
omm=# \du
List of roles
Role name | Attributes
| Member of
-----------±------------------------------------------------------------------------------------------------------
-----------±----------
gaussdb | Sysadmin
| {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyad
min, UseFT | {}
reole1111 | Cannot login, Sysadmin
| {}
role3 |
| {}

role2 | Cannot login
+| {}
| Role valid begin 2022-01-01 00:00:00+08
|
omm=# grant all privileges to role3;

omm=# \du
List of roles
Role name | Attributes
| Member of
-----------±------------------------------------------------------------------------------------------------------
-----------±----------
gaussdb | Sysadmin
| {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyad
min, UseFT | {}
reole1111 | Cannot login, Sysadmin
| {}
| {}

role2 | Cannot login
+| {}
| Role valid begin 2022-01-01 00:00:00+08
|
role3 | Sysadmin

omm=# revoke omm from role3;
WARNING: role “role3” is not a member of role “omm”
REVOKE ROLE

删除所有创建角色

omm=# \du
List of roles
Role name | Attributes
| Member of
-----------±------------------------------------------------------------------------------------------------------
-----------±----------
gaussdb | Sysadmin
| {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyad
min, UseFT | {}
reole1111 | Cannot login, Sysadmin
| {}
role2 | Cannot login
+| {}
| Role valid begin 2022-01-01 00:00:00+08
|
role3 | Sysadmin
| {}

omm=# drop role role1111;
ERROR: role “role1111” does not exist
omm=# drop role reole1111;
DROP ROLE
omm=# drop role role2;
DROP ROLE
omm=# drop role role;3;
DROP ROLE
omm=# \du
List of roles
Role name | Attributes
| Member of
-----------±------------------------------------------------------------------------------------------------------
-----------±----------
gaussdb | Sysadmin
| {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyad
min, UseFT | {}

最后修改时间:2021-12-08 14:43:03
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论