【运维心得】Mysql8白名单设置
环境: Centos7 Mysql8
登陆mysql
mysql -u root -p
查看所有的用户
select HOST,user ,grant_priv from user ;
限定单ip
update user set host = '限制原本无限制的root' where user = 'root' where host = '%';
添加限制ip段
增加新的ip字段
172.17.20 换成指定前缀,如果需要配置成172.17前两位,需要设置为172.17.%.%
CREATE user 'root'@'172.17.20.%' IDENTIFIED with 'mysql_native_password' by '你的密码';
授权
GRANT ALL on *.* TO 'root'@'172.17.20.%';
刷新权限
flush privileges;
删除指定用户
drop user canal@'172.17.20.%';
如果root用户无grant_priv权限
update mysql.user set Grant_priv="Y" where user="root" and host="localhost";
flush privileges;
最好设置下入站出站规则, 更加安全