通过show grants for ‘username’@’ip’查看用户授权信息;
通过revoke xxx from ‘username’@’ip’撤销用户权限。
如:
创建用户
create user 'readonly'@'%' identified with mysql_native_password by 'Aa123456,';
用户授权
grant select,delete on *.* to 'readonly'@'%'; grant insert on *.* to 'readonly'@'%';
看用户授权
show grants for 'readonly'@'%'\G
- 撤销用户权限
撤销readonly用户的insert和delete权限。
revoke insert,delete on *.* from 'readonly'@'%';
再检查readonly权限可以看到只剩下select权限了。