目录
数据控制语言(DCL:Data Control Language): 它的语句通过GRANT或REVOKE获得许可,确定单个用户和用户组对数据库对象的访问。某些RDBMS可用GRANT或REVOKE控制对表单个列的访问。
1、用户管理
1.1 创建用户
create user linyunxi@'192.168.8.%' identified by 'Linyunxi@123';
1.2 删除用户
drop user linyunxi@'192.168.8.%';
1.3 修改用户
create user linyunxi@'192.168.8.%' identified by 'Linyunxi@123';
rename user linyunxi@'192.168.8.%' to linyun@'%';
1.4 修改密码
第一种方法
set password for linyunxi@'%'=password('Linyun@123');
第二种方法
alter user linyun@'%' identified by 'Linyunxi@123';
第三种方法(忘记密码时,必须使用此方法修改密码)
update mysql.user set authentication_string=password('Lin@123456') where user='root' and host='localhost';
root修改自己密码(linux命令行执行)
mysqladmin -uroot -p'Linyunxi@123' password 'Lin@123456'
2、权限管理
关于权限方面的修改,注意刷新权限,否则有可能不生效
2.1 授权
grant all on company.* to lyx@'%' identified by 'Lyx@123456';
flush privileges;
2.2 取消授权
revoke all on company.* from lyx@'%';
flush privileges;
3、查看授权信息
3.1 查看授权语句
show grants for lyx@'%';
3.2 查看生效的授权信息
select * from mysql.user where user='lyx'\G
3.3 查看具体到库的权限
select * from mysql.db where user='lyx'\G