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

openGauss每日一练第4天|学习心得

原创 Alex 2021-12-15
313

一晃就学习openGauss第四天了,学习的内容不难,容易掌握,特别是训练环境以及训练的指南,特别有帮助,步入正题如下:

1.登录数据库

omm@modb:~$ gsql -r
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:03:52 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.


2.查看角色列表
omm=# \du
List of roles
Role name | Attributes | Memb
er of
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
gaussdb | Sysadmin | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}


3.创建角色manager1, manager2, manager3
omm=# CREATE ROLE manager1 IDENTIFIED BY 'test_123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

omm=# CREATE ROLE manager2 LOGIN SYSADMIN IDENTIFIED BY 'test_456';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# CREATE ROLE manager3 WITH LOGIN PASSWORD 'test_789' VALID BEGIN '2021-12-10' VALID UNTIL '2021-12-30';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

再来查看一下角色列表
omm=# \du+
List of roles
Role name | Attributes | Memb
er of | Description
-----------+------------------------------------------------------------------------------------------------------------------+-----
------+-------------
gaussdb | Sysadmin | {}
|
manager1 | Cannot login | {}
|
manager2 | Sysadmin | {}
|
manager3 | Role valid begin 2021-12-10 00:00:00+08 +| {}
|
| Role valid until 2021-12-30 00:00:00+08 |
|
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
|
omm=#


4.授权角色
omm=# ALTER ROLE manager1 SYSADMIN LOGIN;
ALTER ROLE
omm=# \du+ manager1
List of roles
Role name | Attributes | Member of | Description
-----------+------------+-----------+-------------
manager1 | Sysadmin | {} |

5.修改角色密码
omm=# ALTER ROLE manager2 IDENTIFIED BY 'abcd@123' ;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE

6.重命名角色
omm=# ALTER ROLE manager2 RENAME TO manager20;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE

6.授权omm角色给角色名为manager1
omm=# GRANT omm to manager1 with admin option;
GRANT ROLE

7.回收角色manager1的权限
omm=# revoke all privilege from manager1;
ALTER ROLE

8.删除角色权限manager1,manager20,manager3

omm=# drop role manager1;

DROP ROLE
omm=# drop role manager20;
DROP ROLE
omm=# drop role manager3;
DROP ROLE
omm=#


作业
omm=# create role role1 SYSADMIN IDENTIFIED BY 'test_456';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

omm=# create role role2 PASSWORD 'test_789' VALID BEGIN '2021-12-10' VALID UNTIL '2021-12-30';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

omm=# create role role3 with login PASSWORD 'test_789' ;
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

omm=# alter role role1 rename to role10;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE

omm=# alter role role2 identified by 'opengauss_123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE

omm=# grant omm to role3 with admin option;
omm=# GRANT ROLE

omm=# revoke all privileges from role3;
ALTER ROLE

omm=# drop role role10;
DROP ROLE
omm=# drop role role2;
DROP ROLE
omm=# drop role role3;
DROP ROLE
omm=# \du
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
gaussdb | Sysadmin | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}

List of roles
Role name | Attributes | Memb
er of
omm=# \du+
List of roles
Role name | Attributes | Memb
er of | Description
-----------+------------------------------------------------------------------------------------------------------------------+-----
------+-------------
gaussdb | Sysadmin | {}
|
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
|

omm=#


今天 的内容就这么多,都是关于角色的管理方面,比较容易掌握。

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

评论