首先查看防火墙是否打开,如果打开关闭防火墙
[root@LinuxMySQL ~]# sudo systemctl status firewalld
[root@LinuxMySQL ~]# sudo systemctl stop firewalld
然后设置登录的账号为任意ip地址都可登录mysql
update user set host="%" where user="root";
修改/etc/my.cnf文件
添加
bind-address = 0.0.0.0
然后重启mysql
[root@LinuxMySQL ~]# sudo systemctl restart mysql