Mysql之DCL
DCL英文全称Data Control Language(数据控制语言)
用户管理
- 查询用户
use mysql;
select * from user ;
- 创建用户
create user '用户名'@'主机名' identified by '密码'
- 修改用户名密码
alter user c identified with mysql_native_password by '密码'
- 删除用户
drop user '用户名'@'主机名'
主机名可以使用%匹配所有主机
权限管理
- 查询用户权限
show grants for '用户名'@'主机名';
例:show grants for 'jx'@'localhost';
- 授予用户权限
grant all on 数据库名.表名 to '用户名'@'主机名';
例:grant all on itcast.* to 'jx'@'localhost'; //前提 itcast数据库已存在
- 撤销用户权限
revoke all on 数据库名.表名 '用户名'@'主机名';
例:revoke all on itcast.* from 'jx'@'localhost';
多个权限之间使用逗号分隔