DCL-权限控制
mysql常用权限:
1.查询权限:show grants for '用户名'@'主机名';
2.授予权限:grants 权限列表 on 数据库名.表名 to '用户名'@'主机名';
3.撤销权限:revoke 权限列表 on 数据库名.表名 from '用户名'@'主机名';
注意:
多个权限之间,使用逗号分隔
授权时,数据库名和表名可以使用通配符*表示,代表所有
代码:
create user 'heima'@'%' identified by '123456';
show grants for 'heima'@'%';/*查询权限 */
grant all on itcast.* to 'heima'@'%';/*授予权限 */
revoke all on itcast.* from 'heima'@'%';/*撤销权限 */
show grants for 'heima'@'%';/*查询权限 */
grant all on itcast.* to 'heima'@'%';/*授予权限 */
revoke all on itcast.* from 'heima'@'%';/*撤销权限 */