摘要:一般使用GUI工具连接虚拟机数据库是不能直接连接的,需要设置服务可被远程客户端访问
1.使用root登录
mysql -uroot -p
2.设置服务可被所有远程客户端访问
select Host,User from mysql.user; -- 查询到他的host为localhost
update mysql.user set Host = '%' where user = 'root'; -- 将其修改为所有或者具体的ip地址
3.关闭防火墙
systemctl disable firewalld ---永久关闭防火墙
systemctl stop firewalld ---暂时关闭防火墙
4.重启mysql服务
systemctl restart mysqld ---重启mysql服务
5.使用Navicat 连接
使用虚拟机的ip地址作为主机,输入数据库的用户名和密码,进行测试连接