一.查看linux防火墙状态,关闭防火墙
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
再尝试连接
二.如果不行,在mysql命令行中输入:
GRANT ALL PRIVILEGES ON . TO ‘user’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION; //授权所有主机连接到mysql服务器
FLUSH PRIVILEGES;