实验五MYSQL权限与安全
实验平台:安装MYSQL数据库的PC
实验目的:1.理解MYSQL权限管理的工作原理。
2.掌握MYSQL中账号管理。
实验具体要求(在导入的教学管理STM数据库中完成):
1、用户的创建
①利用CREATE USER语句创建用户user1、user2、user3,密码均为’123456’。
mysql> create user 'user1'@'localhost' identified by '123456', 'user2'@'localhost' identified by '123456', 'user3'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
②利用INSERT INTO语句向USER表创建用户user4,密码均为’123456’。
mysql> insert into http://www.doczj.com/doc/e59c80c2be1e650e53ea9924.htmler(host,user,password,ssl_cipher,x509_issuer,x509_subject) values('localhost','user5',password('123456'),'','','');
Query OK, 1 row affected (0.00 sec)
③利用GRANT语句创建用户user5,密码均为’123456’,且为全局级用户。
mysql> grant select,insert,update on *.* to 'user5'@'localhost' identified by'123456';
Query OK, 0 rows affected (0.00 sec)
2、用户授权(利用GRANT语句)
①授予user1用户为数据库级用户,对STM拥有所有权。
mysql> grant all on *.* to 'user1'@'localhost' identified by'123456';
Query OK, 0 rows affected (0.01 sec)
②授予user2用户为表级用户,对STM中的student表select,create,drop权限。
mysql> grant select,create,drop on stm.学生to 'user2'@'localhost' identified by
'123456';
Query OK, 0 rows affected (0.00 sec)
③授予user3用户为列级用户,对STM中的student表的sname列用户select和update 权限。
mysql> grant select,update(姓名) on stm.学生to 'user2'@'localhost' identified by'123456';
Query OK, 0 rows affected (0.02 sec)
④授予user4用户为过程级用户,对STM中的get_student_by_sno存储过程拥有EXECUTE执行的权限。