If you can't connect to MySQL over PHP from your localhost, then try something like:


In the Windows/System32/drivers/etc/hosts file remove the entry like this: 
::1             localhost 


and make sure you still have: 
127.0.0.1       localhost


Taken from here.