权限管理
权限管理:
1.创建账号:
#本地账号
create user 'egon1'@'localhost' identified by '123'; # mysql -uegon1 -p123
#远程账号
create user 'egon1'@'192.168.31.10' identified by '123'; # mysql -uegon1 -p123 -h 服务器ip #允许某个ip地址登陆
create user 'egon1'@'192.168.31.%' identified by '123'; # mysql -uegon1 -p123 -h 服务器ip #允许某个网段地址登陆
create user 'egon1'@'%' identified by '123'; # mysql -uegon1 -p123 -h 服务器ip #允许所有地址登陆
2.授权:
user: *.* #最高授权允许操作所有数据库
db: db1.* #允许操作某一个数据库
tables_priv:db1.t1 #允许操作某一个数据库的某一张表
columns_priv:id,name #允许操作某一个数据库的某一张表的字段
grant all on *.* to 'egon1'@'localhost'; #授权所有权限给'egon1'@'localhost'
grant select on *.*to 'egon1'@'localhost'; #授权查看所有数据库给'egon1'@'localhost'
revoke select on *.* from 'egon1'@'localhost' #回收授权查看所有数据库给'egon1'@'localhost'
浙公网安备 33010602011771号