mysql error 2005 - Unknown MySQL server host 'localhost'(11001)

165.8k Views Asked by At

I was using mysql 5.6.11. It usually turned down and show me this:

2005 - Unknown MySQL server host 'localhost'(11001).

Currently my resolution is to turn off the network, then it returns to normal. I had searched a lot, but no answer is revalent to it. So, does anyone know the reason?

6

There are 6 best solutions below

3
On BEST ANSWER

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

modify list of host names for your system:

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

(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.

0
On

I got the same error below:

ERROR 2005 (HY000): Unknown MySQL server host '%' (11001)

Because for 'john'@'%', I used -h '%' to log in to MySQL as shown below:

mysql -u john -h '%' -p

So instead, I used -h '' as shown below, then I could log in to MySQL:

mysql -u john -h '' -p
0
On

Follow these steps to fix this error Use \connect [email protected] instead of \connect root@localhost

if it doesn't work then go to C:\Windows\System32\drivers\etc\hosts and check the IP address attached to host name. use that IP, so it will be. \connect root@the_ip_address_you_found

0
On

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:

  1. Go to folder:

    C:\AppServ\MySQL
    
  2. Right click and Run as Administrator these files:

    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.

3
On

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):

  1. Disconnect the network.
  2. Stop mysql service (if windows, try from services.msc window)
  3. Connect to network.
  4. Try to start the mysql and see if it starts correctly.
  5. Check for system logs anyways to be sure that there is no error in starting mysql service.
  6. If all goes well try connecting.
  7. If fails, try to do a telnet localhost 3306 and see what output it shows.
  8. Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.

This should ideally resolve the issue you are facing.

1
On

I did several tests, but when I went to check it was just the service that hadn't started. just go to Win+R, put services.msc and start the service