连接代码:
<?

$link = mysql_connect('localhost','root','zxc8585');
if(!$link) {
echo "数据库链接失败";
}else {
echo "数据库链接成功";
}
mysql_close();
?>

结果却返回这个:
Warning: mysql_connect(): No such file or directory in /Library/WebServer/Documents/mysql.php on line 4
数据库链接失败
Warning: mysql_close(): no MySQL-Link resource supplied in /Library/WebServer/Documents/mysql.php on line 10

往上找了很多资料都没解决,后来发现配置phpMyAdmin的时候,需要将

$cfg['Servers'][$i]['host'] = 'localhost';

修改为

$cfg['Servers'][$i]['host'] = '127.0.0.1';

不太清楚为什么会这样,看到一篇文章可做参考:http://www.jb51.net/article/50422.htm

 

相关文章:

  • 2021-06-21
  • 2021-08-17
  • 2022-01-19
  • 2021-04-13
  • 2021-12-30
  • 2022-12-23
  • 1970-01-01
  • 2021-06-03
猜你喜欢
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
相关资源
相似解决方案