首先开启远程连接
mysql -uroot -p
update user set host='%' where user ='root';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
flush privileges;
如果还是不行,就检查防火墙是不是开了
firewall-cmd --state
如果防火墙是开启的,就允许3306端口访问,或者关闭防火墙
systemctl stop firewalld.service