权限管理(root)
1、创建账号 # 本地账号 create user'egon1'@'localhost' identified by '123'; # mysql -uegon1 -p123 # 远程账号,客户端ip(192.168.31.10) create user'egon1'@'192.168.31.10' identified by '123'; # mysql -uegon1 -p123 -h 服务端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 3、授权 user: *.* ## 所有表所有权限 db: db1.* ## db1库下所有权限 tables_priv: db1.t1 ## 表t1 columns_priv: id,name ## 表中字段 放权 grant all on *.* to 'egon1'@'localhost'; grant select on *.* to 'egon1'@'localhost'; 回收权限 revoke select on *.* from 'egon1'@'localhost'; select * from mysql.user\G ## cmd命令查看 对库 grant select on db1.* to 'egon1'@'localhost'; revoke select on db1.* from 'egon1'@'localhost'; 对表 grant select on db1.t1 to 'egon1'@'localhost'; revoke select on db1.t1 from 'egon1'@'localhost'; 对字段 grant select(id,name),update(age) on db1.t1 to 'egon1'@'localhost'; revoke select(id,name),update(age) on db1.t1 from 'egon1'@'localhost';