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

 

 

https://stackoverflow.com/questions/10792862/rails-development-cant-connect-to-mysql-server-on-localhost-10061

 

My best guess is that the machine, which you indicated as Windows, has IPv6 networking enabled. Thus when you try to go to localhost, it is resolving to "::1". This is in fact the local machine, however, default MySQL installs normally have bind-address set to 127.0.0.1, which would cause localhost to fail in this setup.

You might be able to verify this by running ping localhost from the command prompt, and seeing if you get a response like:

 Reply from::1: time<1ms

To fix this, you can change your config to specify:

 host:127.0.0.1

Alternately, you can change MySQL's configuration to allow a different bind-address, e.g. localhost instead of 127.0.0.1.

 

 

 

原因:ipv6造成的

 

解决:

方法1:   my.in 文件修改配置 bind-address=localhost,然后重启mysql服务  (测试无效)

方法2: C:\Windows\System32\drivers\etc  修改hosts文件添加如下配置:(测试无效)

               localhost 127.0.0.1

           

 方法3: 官网重新下载一个mysql5.1版本的msi安装包,重新安装了一遍解决.(有效,问题解决)

               出问题的mysq5.1是网上下载的绿色免安装的版本

猜你喜欢

转载自zhouchaofei2010.iteye.com/blog/2397890