mysql_connect提示"No such file or directory"错误"
有些朋友在使用mysql连接时会出现No such file or directory错误提示,下面我来总结解决办法。
连接代码
代码如下 | 复制代码 |
$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。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)