《数据库系统实验》
实验报告
题目 |
实验10——数据库安全性 |
一、实验环境:
1、操作系统:Windows 11 22H2;
2、DBMS :mysql 8.0 CE;
二、实验内容与完成情况
10.1 创建名为RONALDO,密码为NIKE的用户,然后显示MySQL中user表的内容
SQL语言:
CREATE USER RONALDO IDENTIFIED BY 'NIKE';
select user from mysql.user;
结果:
10.2 将用户RONALDO改名为TEACHER,然后显示MySQL中user表的内容
SQL语言:
rename user RONALDO to TEACHER;
select user from mysql.user;
结果:
10.3 把TEACHER的密码改为hello
SQL语言:
set password for TEACHER='hello';
10.4 删除TEACHER用户
SQL语言:
drop user TEACHER;
select user from mysql.user;
结果:
10.5 创建三个新用户,然后显示MySQL中user表的内容
SQL语言:
CREATE USER Chris1@'sql.com' identified by '1234';
CREATE USER Chris2@'%' identified by '12345';
CREATE USER Chris3@'%.com' identified by '123456';
select * from mysql.user;
结果:
10.6 授予[email protected]用户在student表上的select、update权限,并且他可以传递给其他用户。以[email protected]用户登录,把在student表上的select,update权限授予Chris2@%
依据实验要求,我们将上述实验内容的‘[email protected]’更改为‘Chris1@%’。在进行实验之前,我们需要先创建Chris1@%用户。
SQL语言:
CREATE USER Chris1@'%' identified by '1234';
grant select,update on jxgl.student to Chris1@'%'
with grant option;
show grants for Chris1@'%';
结果:
接着,我们在终端登入Chris1@%,并授予Chris2@%权限。如下图所示。
SQL语言:
show grants for Chris2@'%';
结果:
10.7 授予Chris3@%.com用户在jxgl数据库中所有表的select权限
SQL语言:
grant select on jxgl.* to Chris3@'%.com';
show grants for Chris3@'%.com';
结果:
10.9 回收Chris1@%的权限,并且查看Chris2@%的权限
SQL语言:
revoke select,update,grant option on jxgl.student from Chris1@'%';
show grants for Chris2@'%';
结果: