mysql 错误 2005 - 未知的 MySQL 服务器主机 'localhost'(11001)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16580370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql error 2005 - Unknown MySQL server host 'localhost'(11001)
提问by user2388626
I was using mysql 5.6.11,it usually turned down and show me this:
我正在使用 mysql 5.6.11,它通常被拒绝并向我展示这个:
2005 - Unknown MySQL server host 'localhost'(11001).
2005 - 未知的 MySQL 服务器主机 'localhost'(11001)。
Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?
目前我的解决方案是关闭网络,然后恢复正常。我搜索了很多,但没有答案与之相关。那么,有人知道原因吗?
回答by GaneshP
ERROR 2005 (HY000): Unknown MySQL server host 'localhost' (0)
错误 2005 (HY000):未知的 MySQL 服务器主机 'localhost' (0)
modify list of host names for your system:
修改系统的主机名列表:
C:\Windows\System32\drivers\etc\hosts
C:\Windows\System32\drivers\etc\hosts
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
127.0.0.1 localhost
在我的情况下,该条目是 0.0.0.0 localhost 这导致了所有问题
(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”的 DNS 解析为 IP 地址 127.0.0.1。
回答by Mizo Games
I have passed through that error today and did everything described above but didn't work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:
我今天已经通过了那个错误并做了上面描述的所有事情,但对我没有用。于是决定查看核心问题,登录Windows 7的MySQL根文件夹,做了如下解决:
Go to folder:
C:\AppServ\MySQL
Right click and Run as Administrator these files:
mysql_servicefix.bat mysql_serviceinstall.bat mysql_servicestart.bat
转到文件夹:
C:\AppServ\MySQL
右键单击并以管理员身份运行这些文件:
mysql_servicefix.bat mysql_serviceinstall.bat mysql_servicestart.bat
Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.
然后关闭整个资源管理器窗口并重新打开它或清除缓存,然后再次登录到 phpMyAdmin。
回答by Himanshu Bhardwaj
The case is like :
情况是这样的:
mysql connects will localhost when network is not up.
mysql cannot connect when network is up.
You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):
您可以尝试以下步骤来诊断和解决问题(我猜测是其他一些服务阻塞了托管 mysql 的端口):
- Disconnect the network.
- Stop mysql service (if windows, try from services.msc window)
- Connect to network.
- Try to start the mysql and see if it starts correctly.
- Check for system logs anyways to be sure that there is no error in starting mysql service.
- If all goes well try connecting.
- If fails, try to do a telnet localhost 3306and see what output it shows.
- Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.
- 断开网络。
- 停止 mysql 服务(如果是 windows,请从 services.msc 窗口尝试)
- 连接到网络。
- 尝试启动mysql,看看它是否正确启动。
- 无论如何检查系统日志以确保启动mysql服务没有错误。
- 如果一切顺利,请尝试连接。
- 如果失败,请尝试执行telnet localhost 3306并查看它显示的输出。
- 尝试更改托管 mysql 的端口,默认为 3306,您可以更改为其他未使用的端口。
This should ideally resolve the issue you are facing.
理想情况下,这应该可以解决您面临的问题。