Can't connect to MySQL server on 'localhost'

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

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

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

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

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

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

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

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

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

答案摘录以下:orm

this issue is vary to solve by windows server usersserver

  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.

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