navicat连接服务器报错lost connection to MySQL server at "waiting for initial communication packet"

## navicat连接服务器报错lost connection to MySQL server at “waiting for initial communication packet” ##
用tp在虚拟机lnmp环境下运行项目,发现用nat方式数据库就能直接用Navicat连接上,用桥接模式就会报错2013-lost connection to MySQL server at “waiting for initial communication packet”
##解决方法:
找到 mysql的配置文件/usr/my.cnf 添加skip-name-resolve,skip-name-resolve是禁用dns解析,所以在mysql的授权表中就不能使用主机名了,只能使用IP 。
此时可能出现的问题是:项目里的配置文件也不能用127.0.0.1来设置了,访问数据库只能用服务器的ip地址例如:192.168.4.116这样项目运行也没问题了,用navicat连接也没问题了!

猜你喜欢

转载自blog.csdn.net/weixin_43025071/article/details/82385880
今日推荐