navicat连接虚拟机上的数据库

101 阅读1分钟

系统:centos8

报错提示符:“2002-Can't connect to server on '192.168.***.**'(10060)”

出现报错的原因

1、网络不通

2、MySQL服务未启动

3、防火墙未关闭

systemctl stop firewall
systemctl disable firewall

4、修改了MySQL的端口,防火墙未监听端口

1.1 MySQL的配置文件位置

Linux文件位置通常位于/etc/my.cnf

1.2 修改配置文件

找到配置文件后,打开并编辑它。你需要找到[mysqld]部分,并更改其中的port参数。例如,将默认端口3306更改为3307:

2.1更新防火墙规则

如果使用firewalld,使用以下命令

sudo firewall-cmd --permanent --add-port=3307/tcp
sudo firewall-cmd --reload

3.1重启MySQL服务

sudo systemctl restart mysql

3.2 检查使用的端口号

firewall-cmd --list-all