教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 mysql_connect提示"No such file or directory"错误"

mysql_connect提示"No such file or directory"错误"

发布时间:2018-12-10   编辑:jiaochengji.com
教程集为您提供mysql,connect提示"No such file or directory"错误"等资源,欢迎您收藏本站,我们将为您提供最新的mysql,connect提示"No such file or directory"错误"资源
有些朋友在使用mysql连接时会出现No such file or directory错误提示,下面我来总结解决办法。

连接代码

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6251')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6251>

$this->linkid = @mysql_pconnect($host, $user, $password) or die(mysql_error());


Make a phpinfo() page.  Look for ‘mysql.default_socket‘, ‘mysqli.default_socket‘, and

‘pdo_mysql.default_socket‘.  Remember their value; this is where PHP is trying to connect to MySQL.

解决办法

1.首先确定是mysql_connect()和mysql_pconnect()的问题,故障现象就是函数返回空,而mysql_error()返回“No

such file or directory”。
2.写个phpinfo页面,找到mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket。
3.启动mysql,执行命令 STATUS; 记下UNIX socket的值。
4.如果2和3的值不一样,则打开php.ini(可以从phpinfo页面中找到php.ini的位置,默认是/private/etc/php.ini)

,将2中提到的三个配置项的值改成3的值。
5.重启apache。

您可能感兴趣的文章:
mysql_connect提示"No such file or directory"错误"
Centos安装libxml2 'bin/rm: cannot remove libtoolT'...的解决方法
php使用session提示[function.session-start]: open解决方法
mysqli连接提示 Warning: mysqli::mysqli(): (HY000/2002): No such file or directory
无法读取mysql库文件的故障排除
mysqli使用localhost问题 Warning: mysqli::mysqli(): (HY000/2002): No such file or directory
bad interpreter的解决方法(sh文件在linux下无法执行)
PHP的错误是什么
关于PHP中extension加载顺序问题的解决方法
解决:failed to open stream: No such file or directory in

[关闭]
~ ~