mysql error 2005

有的时候偶尔会出现这个问题 2005 Unknown MySQL server host 'localhost' (11001),刚开始重启电脑ok了,但是不能每次出现这个问题就重启电脑吧,太麻烦了,总得找到原因。

ERROR 2005 (HY000): Unknown MySQL server host 'localhost' (0)

修改文件C:WindowsSystem32driversetchosts

添加127.0.0.1 localhost

在我的文件中这入口也是0.0.0.0 localhost:所以导致了这个问题,具体问什么会导致就不太清楚了

参考:http://stackoverflow.com/questions/16580370/mysql-error-2005-unknown-mysql-server-host-localhost11001

modify list of host names for your system:

C:WindowsSystem32driversetchosts

Make sure that you have the following entry:

127.0.0.1 localhost

In my case that entry was 0.0.0.0 localhost which caussed all problem

(you may need to change modify permission to modify this file)

This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.

localhost是host文件中代表127.0.0.1的一个名称, 如果在这个文件中去掉的话localhost就没有实际意义

如果喜欢作者的文章,请关注"写代码的猿"订阅号以便第一时间获得最新内容。本文版权归作者所有,欢迎转载. 

原文地址:https://www.cnblogs.com/yuan1225/p/3467085.html