不知不觉学习opengauss第五天了,时间还过的真快!废话不多说,直接看下面操作!
1.登录数据库环境
Welcome to 墨天轮.
This is Web Terminal of modb.pro; Good Good Study, Day Day Up.
root@modb:~# su - omm
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=# CREATE USER jim PASSWORD 'abcd@123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
omm=# CREATE USER kim IDENTIFIED BY 'abcd@456';CREATE ROLE
omm=#
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# CREATE USER dim CREATEDB PASSWORD 'abcd@789';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
3.查看用户
omm=# \du
List of roles
Role name | Attributes | Memb
er of
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
dim | Create DB | {}
gaussdb | Sysadmin | {}
jim | | {}
kim | | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
4.修改用户密码
omm=# ALTER USER jim IDENTIFIED BY 'Abcd@123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE
5.授权用户jim createrole权限
omm=# ALTER USER jim CREATEROLE;
ALTER ROLE
omm=# \du
List of roles
Role name | Attributes | Memb
er of
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
dim | Create DB | {}
gaussdb | Sysadmin | {}
jim | Create role | {}
kim | | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
6.授权jim权限给kim
omm=# grant jim to kim;
omm=# GRANT ROLE
7.授所有权限给dim
GRANT ALL PRIVILEGES TO dim;
ALTER ROLE
8.重命名dim为tim
omm=# alter user dim rename to tim;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE
omm=# \du
List of roles
Role name | Attributes | Memb
er of
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
gaussdb | Sysadmin | {}
jim | Create role | {}
kim | | {jim
}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
tim | Create DB, Sysadmin | {}
9.撤消kim的权限
omm=# revoke jim from kim;
REVOKE ROLE
10.回收tim的所有权限
omm=# revoke all privilege from tim;
ALTER ROLE
omm=# \du
List of roles
Role name | Attributes | Memb
er of
-----------+------------------------------------------------------------------------------------------------------------------+-----
------
gaussdb | Sysadmin | {}
jim | Create role | {}
kim | | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
tim | Create DB | {}
11.删除用户
omm=# drop user tim;
DROP ROLE
omm=# drop user jim;
DROP ROLE
omm=# drop user kim;
DROP ROLE
omm=#
作业
omm=# create user user1 createrole password 'abcd@789';
^CTICE: The encrypted password contains MD5 ciphertext, which is not secure.
omm=# ROLE
omm=# create user user2 createdb password 'abcd@789';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# ALTER USER user2 IDENTIFIED BY 'Abcd@123';
omm=# create user user3 identified by 'Abcd@123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# grant user1 to user3;
GRANT ROLE
omm=#
omm=# revoke all privileges from user3;
ALTER ROLE
omm=# alter user user1 identified by 'Abc@1234';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
ALTER ROLE
omm=# alter user user2 rename to u2;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE
omm=# grant user1 to user1 with admin option;
ERROR: role "user1" is a member of role "user1"
omm=# create user user3 identified by 'Abcd@123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# grant user1 to user3;
GRANT ROLE
omm=# revoke all privileges from user3;
ALTER ROLE
omm=# drop user user1;
DROP ROLE
omm=# drop user u2;
DROP ROLE
omm=# drop user user3;
DROP ROLE
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 | {}
tim | Create DB | {}
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 | {}
|
tim | Create DB | {}
|
omm=#




