需要先关闭虚拟机的防火墙,才能够连接成功
firewalld防火墙
启动: systemctl start firewalld
关闭: systemctl stop firewalld
停止: systemctl disable firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
查看所有打开的端口:
firewall-cmd --zone=public --list-ports
连接数据库
mysql -u root -p
赋予root用户远程连接的权限
grant all privileges on *.* to 'root'@'%' identified by '密码';
flush privileges; //刷新MySQL的系统权限相关表