air air - 3 months ago 14x
PHP Question

mysql_connect taking long time to execute

i have following script in php to login to mysql


$dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
$dbs=mysql_select_db($db_name) OR DIE (mysql_error());

this script was working fine, now i reinstall the O.S
now i have windows 7 and iis7 and PHP Version 5.3.2 & mysql server 5.1
but now this script is not working and taking log time to execute.



On Windows 7 localhost resolves to ::1, and MySQL doesn't support IPv6 as far as I know.

Connecting directly to resolves this problem; but you can edit the hosts file to resolve localhost to, then localhost will work too:

  1. Open C:\Windows\System32\drivers\etc\hosts
  2. Remove the following line, if present: ::1 localhost
  3. Add the following line, if not present: localhost