角色-------
创建角色
创建角色r_his只适用192.168.210.39使用
create role r_his@'192.168.210.39';
创建角色r_his,适用任何ip连上来用
create role r_his@'%';
or
create role r_his;
赋予角色权限
赋予'r_his'@'192.168.210.22'角色 对 test.emp表 进行 查、删、增的权限
grant select,delete,insert on test.emp to 'r_his'@'192.168.210.22';
将角色授权用户
赋予'lala'@'192.168.210.39'用户 'r_his'@'192.168.210.39'角色的权限
grant 'r_his'@'192.168.210.39' to 'lala'@'192.168.210.39';
如果直接写r_his代表'r_his'@'%'
查看角色拥有的权限
查看角色拥有的全新
show grants for 'r_his'@'192.168.210.39';
也能在mysql.user查看是否为角色
select user,host,authentication_string,account_locked from mysql.user;
角色的mysql.user的account_locked是Y,锁定的
收回角色权限
回收'r_his'@'192.168.210.39'角色 对test库所有表的 增、改、删 权限
revoke inset,update,delete on test.* from 'r_his'@'192.168.210.39';
删除角色
删除'r_haha'@'192.168.210.39'和'r_his'@'192.168.210.39'角色
drop role 'r_haha','r_his'@'192.168.210.39';