Can't connect to MySQL server on 'localhost'

今天测试SSH相关代码,服务器启动时控制台报异常:

Communications link failure,The last packet successfully received...

后来打开navicat,发现原来是数据库打不开了,双击报错误 :

Can't connect to MySQL server on 'localhost' (10061);

网上查了很多,众说纷纭,后来看到stackoverflow里有一个解决方法简单易行,试了下果然ok:

1.找到mysql安装目录,比如:C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin

2.打开MySQLInstanceConfig.exe,重新设置相关参数,密码哪怕设置的跟原来一样都行。

完成后数据库即能打开了。

原文http://stackoverflow.com/questions/10892689/cant-connect-to-mysql-server-on-localhost-10061-after-installation

答案摘录如下:

this issue is vary to solve by windows server users

  1. go to this path C:\Program Files\MySQL\MySQL Server 5.1\bin

  2. run this tool "MySQLInstanceConfig.exe"

and config the instatnce again and problem solved.

当然,答主也提到了这一问题的解决方案因人而异。该答案未必适用每一个报这种异常的问题,网上也有其他多种解决方案。如果此路不通,可尝试其他方案。



你可能感兴趣的:(Can't connect to MySQL server on 'localhost')