1.创建新用户
create user 'employee'@'localhost' identified by 'employee123';
2.授权读权限
grant select on employee.department to 'employee'@'localhost';
3.授权读(两个字段)权限
grant select(firt_name,last_name) on employee.employees to 'employee'@'localhost';
4.登录mysql
mysql -uroot -proot123
5.查departments表
use employees;
select * from departments limit 5;
6.查employees表所有字段(报错)
select * from employees limit 5;
7.查employees表两个字段
select first_name,last_name from employees limit 5;
8.执行以下查询,报错
select departments.dept_name,employees.first_name,
employees.last_name
from departments natural join dept_emp natural join employees limit 5;
9.查关联的表
select user();
use employees;
desc departments;
desc dept_emp;
10.授权
grant select(deprt_no,emp_no) on employees.dept_emp to employee@localhost;
grant select (emp_no) on employees.employees to employee@localhost;
11.查看权限
show grants for 'employee'@'localhost'\G;
12.再次查询,不会报错
select departments.dept_name,employees.first_name,
employees.last_name
from departments natural join dept_emp natural join employees limit 5;
13.update数据报错
update employees set first_name='Georgiio' where emp_no=10001;
14.delete数据报错
delete from employees where emp_no=10001;
15.退出
exit