Yesterday, when using phpMyAdmin to connect to MySQL, there was a #2002– server that was not responding (or the socket for the local MySQL server was not configured correctly), but I did not have any problems with the PHP connection.
The code is as follows |
Copy Code |
<?php $link =mysql_connect ("127.0.0.1", "root", "password"); if (! $link) echo "Connect error"; else echo "Connect OK"; ?> |
Later wanted to phase MySQL the address of the database server should be changed to 127.0.0.1,
Specific methods:
Open the config.inc.php we just copied to the phpMyAdmin directory.
Find this phrase:
The code is as follows |
Copy Code |
$cfg [' Servers '] [$i] [' host '] = ' localhost '; Change into $cfg [' Servers '] [$i] [' host '] = ' 127.0.0.1 '; |
This can be the cause of this problem I think it should be the host file resolution problem, we deal with one should be good.