一、授权
1)操作一:授权
允许远程登录: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
5.7引用授权: grant select,create,drop,update,alter on *.* to '${username}'@'%' identified by '${password}' with grant option;
eg: grant select,REFERENCES,create,drop,update,alter on *.* to 'root'@'%' identified by '123456' with grant option;
ps: 解决MySQL5.7 授权问题
1.1)授权所有权
1)命令
grant all privileges on {databasesName}.* to {userName};
说明1: 需要root解决
2)操作二:立即更新
flush privileges;
3)辅助操作:查看权限
show grants for '${username}'@'%';
二、常用命令
1、授权库的所有权
1)命令
grant all privileges on ku_name.* to user_name;
说明1: ku_name,即数据库的名称
说明2: user_name,用户名
2)刷新权限
flush privileges;
~~
2、创建用户并授权只读权限
1)创建用户
CREATE USER 'user_only_read'@'%' IDENTIFIED BY 'wf&#UjpR@edR';
2)授权
GRANT SELECT ON *.* TO 'user_only_read'@'%';
~~