mysql——com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last pa

在windows命令行连接mysql是这样的:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060)

在工程中连接mysql报了如下的错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
Communications link failure Last packet sent to the server was 0 ms ago 

解决的办法:

在mysql的目录找到my.ini,编辑它,添加一行:wait_timeout=1814400

(这么做的原因可以参考博客:https://blog.csdn.net/cynhafa/article/details/19676865)

如果还不能解决的话,应该是防火墙的问题。在控制面板的中关闭windows防火墙。


猜你喜欢

转载自blog.csdn.net/baoyu_g/article/details/80613392