学习过了。
8.0 新增角色管理功能(可先将权限赋给角色,再将角色赋给用户)
create role 'xxx_role'; //角色在mysql.user中创建一个没有密码的用户
grant XXX,XXX,XXX on XXXdb.* to 'xxx_role';
grant 'xxx_role' to 'user1';
show grants for 'user1';
show grants for 'user1' using 'xxx_role';
set default role 'xxx_role' to 'user1'; // 修改用户使用的默认角色,否则用户登录后默认角色为NONE,用户有多个角色需要默认启用,使用set default role all to 'user1';
select * from mysql.default_roles;
revoke XXX,XXX,XXX on XXXdb.* from 'xxx_role'; //回收角色权限
角色是一组权限的集合
课后练习题
mysql8角色实际上就是一个用户,信息存储在mysql.user表中
新增角色功能