Mysql_connect takes a long time to complete

I have a script in php to login to mysql

$db_host="localhost"; $db_user="root"; $db_pass="123"; $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 worked fine, now I am reinstalling the OS now I have windows 7 and iis7 and PHP version 5.3.2 and mysql server 5.1 but now this script does not work and takes registration time.

thanks

+4
source share
3 answers

On Windows 7, localhost resolves to ::1 , and MySQL does not support IPv6, as far as I know.

Direct connection to 127.0.0.1 fixes this problem; but you can edit the hosts to resolve localhost to 127.0.0.1 , then localhost will work too:

  • Open C: \ Windows \ System32 \ drivers \ etc \ hosts
  • Delete the following line, if any: ::1 localhost
  • Add the following line if not: 127.0.0.1 localhost
+13
source

Using:

 $db_host = "127.0.0.1"; 

(or any other IP, for example 192.168.1.2 ), instead of the host name ( localhost ).

+4
source
0
source

Source: https://habr.com/ru/post/1315271/


All Articles