create user 'lili'@'%' identified by '1234';
GRANT SELECT(id) ON test.student TO 'lili'@'%';
用lili
用户登录,执行sql:
select id from student;
select id,name from student; -- 报错
报错内容:[Err] 1143 - SELECT command denied to user ‘lili’@‘localhost’ for column ‘name’ in table 'student
说明name这列没有权限。
用root用户执行语句:
select * from information_schema.COLUMN_PRIVILEGES where grantee like '%lili%';
如图: