实验7数据库安全

实 验 过 程
目的要求:
(1)掌握数据库用户账号的建立与删除方法
(2)掌握数据库用户权限的授予方法
实验准备:
(1)了解数据库安全的重要性
(2)了解数据库用户账号的建立于删除的方法
(3)了解数据库用户权限的授予和回收方法
(共60分,每题5分,错一题扣5分)
实验内容:
1.数据库用户
(1)创建数据库用户user_1和user_2,密码都为1234(假设服务器名为localhost)。

USE MYSQL;
CREATE USER USER_1@LOCALHOST IDENTIFIED BY '1234';
CREATE USER USER_2@LOCALHOST IDENTIFIED BY '1234'

(2)将用户user_2的名称修改为user_3。

rename user user_2@localhost to user_3@localhost;

(3)将用户user_3的密码修改为123456。

set password for user_3@localhost=password('123456');

(4)删除用户user_3。

drop user 'user_3'@'localhost';

(5)以user_1用户身份登陆MySQL,并在Navicate中创建连接。

mysql -uuser_1 -p

输入密码

2.用户权限的授予与收回
(1)授予用户user_1对YGGL数据库Emlpoees表的所有操作权限及查询操作权限。

grant all on table YGGL.Emlpsees to user_1@localhost;

(2)授予用户user_1对Emlpoees表进行插入,修改,删除操作权限。

grant insert,update,delete on table yygl.Emlpoees to user_1@localhost;

(3)授予用户user_1对数据库YGGL的所有权限。

grant all on table yggl.* to user_1@localhost;

(4)授予user_1在Salary表上的SELECT权限,并允许其将该权限授予其他用户。

grant select on table yggl.Salary to user_1@localhost;

(5)回收user_1的Emlpoees表上的SELECT权限。

revoke select on Emlpoees from user_1@localhost;

(6)授予用户user_1所有的用户权限。

revoke all on * to user_1@localhostl;

(7)取消用户user_1所有的权限。

revoke all on * from user_1@localhsot;

实验小结:

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐