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

GBASE 8A 管理员手册(2)权限管理

原创 PEWSGGL 2021-12-15
728

权限管理

用户管理

更多关于用户管理的语法说明,请参见《GBase 8a SQL参考手册》的相关 章节内容。
下面通过两个示例,介绍创建用户和更改用户密码的操作过程。
示例1:使用超级用户root登录,创建一个用户userl。
$ gbase -uroot -p
Enter password:
GBase client 8. 5. 1. 2 build 27952. Copyright (c) 2004-2013, GBase. All Rights
Reserved.
gbase> CREATE USER userl;
Query OK, 0 rows affected
示例2 :使用超级用户root登录,修改用户user1的密码,然后使用user1 的新密码登录。
$ gbase -uroot -p
Enter password:
GBase client 8.5.1.2 build 27952. Copyright (c) 2004-2013, GBase. All Rights
Reserved.
gbase> SET PASSWORD FOR user1 = PASSWORD('H133%_h');
Query OK, 0 rows affected
退出登录,使用use1用户登录,验证修改□令的正确性。
$ gbase -uuserl -p
Enter password:
GBase client 8. 5. 1. 2 build 27952. Copyright (c) 2004-2013, GBase. All Rights Reserved.
gbase>

权限管理

更多关于权限的的语法说明,请参见《GBase 8a SQL参考手册》的相关章 节内容。
下面通过两个示例,介绍权限管理的操作过程。
示例1:使用超级用户root,创建一个user_general用户,该用户具备 SELECT操作的权限。
$ gbase -uroot -p
Enter password:
GBase client 8.5.1.2 build 27952. Copyright (c) 2004-2013, GBase. All Rights Reserved.
gbase> CREATE USER user_general;
Query OK, 0 rows affected
gbase> SET PASSWORD FOR user_general = PASSWORD('H%897_@m');
Query OK, 0 rows affected
--只赋予SELECT权限。*.*代表所有数据库的数据库对象,例如:表,视 图,存储过程。
gbase> GRANT SELECT ON *.* TO user_general;
Query OK, 0 rows affected
gbase> \q
Bye
一使用user—general登录数据库,验证其只具备SELECT权限。
一存在test数据库和一张t1表,这只是为演示示例提前创建完毕的。
$ gbase -uuse七general -p
Enter password:
GBase client 8. 5. 1. 2 build 27952. Copyright (c) 2004-2013, GBase. All Rights Reserved.
gbase> USE test;
Query OK, 0 rows affected
gbase> UPDATE t1 SET a = 11 WHERE a = 10;
ERROR 1142	(42000): UPDATE command denied to user 'user—general'@'localhost'
for table 't1'
gbase> DELETE FROM t1;
ERROR 1142	(42000): DELETE command denied to user 'user_general'@'localhost'
for table 't1'
gbase> SELECT * FROM t1;
+	+
|	a	|
+	+
|	1	|
|	2	|
|	3	|
|	4	|
|	5	|
|	6	|
|	7	|
I	8	|
I	9	I
I	10	I
+	+
10 rows in set
示例2:使用超级用户root,创建一个user_admin用户,该用户具备超级 用户的权限,即全部的权限。
$ gbase -uroot -p
Enter password:
GBase client 8. 5. 1. 2 build 27952. Copyright (c) 2004-2013, GBase. All Rights
Reserved.
gbase> CREATE USER user_admin;
Query OK, 0 rows affected
gbase> SET PASSWORD FOR user_admin = PASSWORD('H%897_@m');
Query OK, 0 rows affected
--赋予全部权限。*.*代表所有数据库的数据库对象,例如:表,视图,存 储过程。
gbase> GRANT ALL ON *.* TO user_admin;
Query OK, 0 rows affected
gbase> \q
Bye
—使用user_admin登录数据库,验证其只具备SELECT权限。
--存在test数据库和一张t1表,这只是为演示示例提前创建完毕的。
$ gbase -uuser_admin -p
Enter password:
GBase client 8. 5. 1. 2 build 27952. Copyright (c) 2004-2013, GBase. All Rights Reserved.
gbase> USE test;
Query OK, 0 rows affected
--可以SELECT数据。
gbase> SELECT * FROM t1;
+	+
| a	|
+	+
|	1	|
|	2	|
|	3	|
|	4	|
|	5	|
|	6	|
|	7	|
|	8	|
|	9	|
|	10	|
+	+
10 rows in set
--可以UPDATE数据。
gbase> UPDATE t1 SET a = 11 WHERE a = 10;
Query OK, 1 row affected
gbase> SELECT * FROM t1;
+	+
|	a	|
+	+
|	1	|
|	2	|
|	3	|
|	4	| 
I	5	I
I	6	|
I	7	|
I	8	I
I	9	I
I	11	I
+	+
10 rows in set
一可以DELETE数据。
gbase> DELETE FROM t1 WHERE a >= 5;
Query OK, 6 rows affected
gbase> SELECT * FROM t1;
+	+
I a	I
+	+
I	1	I
I	2	I
I	3	I
I	4	I
+	+
4 rows	in set
一可以CREATE用户。
gbase> CREATE USER use_test;
Query OK, 0 rows affected
一可以DROP用户。
gbase> DROP USER use_test;
Query OK, 0 rows affected

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

评论