欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Can't connect to MySQL server on 'localhost' (10061) 博客分类: mysqlwin7 mysqIPv6 

程序员文章站 2024-03-23 11:53:16
...

 

 

https://*.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是网上下载的绿色免安装的版本

相关标签: mysq IPv6