Can't connect to MySQL server on 'localhost' (10061), but can via PHP

With WAMP 2.2 serving Apache 2.2.21, MySQL 5.5.16 and PHP 5.3.8 on my Windows XP development machine, I can connect and manage my database via phpMyAdmin or any locally hosted PHP script using a DNS like "mysql:host=localhost;dbname=kwamjing"

When I try to connect to MySQL via a management tool like HeidiSQL or MySQL Query Browser I get

Error 2003 Can't connect to MySQL server on 'localhost' (10061)

Can a firewall block HeidiSQL from accessing 127.0.0.1:3306 but not PHP?

UPDATE:

Looking at my active connections through netstat -an I see only the ipv6 loopback listening on 3306

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:2869           0.0.0.0:0              LISTENING
  TCP    127.0.0.1:80           0.0.0.0:0              LISTENING
  TCP    127.0.0.1:1025         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:2215         127.0.0.1:2216         ESTABLISHED
  TCP    127.0.0.1:2216         127.0.0.1:2215         ESTABLISHED
  TCP    127.0.0.1:2217         127.0.0.1:2218         ESTABLISHED
  TCP    127.0.0.1:2218         127.0.0.1:2217         ESTABLISHED
  TCP    127.0.0.1:5152         0.0.0.0:0              LISTENING
  TCP    192.168.0.103:139      0.0.0.0:0              LISTENING
  TCP    192.168.0.103:2869     192.168.0.1:4530       CLOSE_WAIT
  TCP    192.168.0.103:2869     192.168.0.1:4532       CLOSE_WAIT
  TCP    [::]:135               [::]:0                 LISTENING       0
  TCP    [::]:2869              [::]:0                 LISTENING       0
  TCP    [::]:3306              [::]:0                 LISTENING       0

Solution 1:

As you are only listening on ipv6, php must have figured this out and is making an ipv6 connection.

HeidiSQL perhaps doesn't support ipv6 and is attempting to connect to mysql on ipv4 and is failing. If you change your bind-address in the my.cnf mysqld section to

bind-address=127.0.0.1

it should fix it.