SQL语句---DCL

发布时间 2023-08-04 20:06:03作者: harper886

SQL语句---DCL

image-20230804194501103

image-20230804194924157

创建用户itcast只能多在当前主机localhost访问,密码123456;

create user 'itcast'@'localhost' identified  by '123456';

-创建用户heima可以在任意主机访问该数据库,密码123456:

create user 'heima'@'%' identified by'123456';

修改用户heima的访问密码为1234;

alter user 'heima'@'%' identified with mysql_native_password  by '1234';

--则除itcast@localhost用户

drop user 'itcast'@'localhost';

DCL-权限控制

image-20230804195200439

查询权限

image-20230804195345193

image-20230804200052637

  1. 查询权限
show grants  for 'heima'@'%';

授予权限

grant all on example.* to 'heima'@'%';

撤消权限

revoke all on example.* from 'heima'@'%';

image-20230804200405431