Search code examples
mysqlwampwampserver

Wamp mysql : ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)


I installed wampserver on my xp machine month ago.. Now when I try to connect to mysql via phpmyadmin or mysql console I get the error :

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

Wamp icon in the tray is green meaning it's running ok.. I checked for mysql service and it's running and using the port 3306 .. I turned off the firewall.. I tried everything and it's not working.. I eventually uninstalled wamp totally and removed all its files and re-installed it again and same error.. When I try to telnet localhost 3306 it doesn't connect and I get the error :

Could not open connection to the host on port 3306: connect failed

I searched the web for hours, but didn't find any working solution. It seems that many people are having the same problem and most of them didn't find the solution.


Solution

  • Ok .. searching the internet for more several hours I've found one little clue that actually fixed my problem.

    When I type netstat -a I get a list of active ports including 3306 (the one mysql uses). The Foreign Address column for some ports is 0.0.0.0.0 but for 3306 is [::]:0. I'm not a network guy but it turned out that it means it's a IPv6 port and it should be IPv4.

    Adding the following line in the file my.ini under [mysqld] and restarting the service solved the problem.

    bind-address=127.0.0.1
    

    Note

    • My wamp version is 2.4 and mysql version is 5.6.12 running under win XP.

    • my.ini file for me is located at c:\wamp\bin\mysql\mysql5.6.12.

    Hope this helps who suffered my pain.