1、数据库没有授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
2、firewall防火墙没有开放端口
添加端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙
systemctl restart firewalld.service
查看所有开放的端口
firewall-cmd --list-ports
原文链接:https://blog.csdn.net/jiuzhibuguniao/java/article/details/80473656