Warning: mysqli::real_connect(): (HY000/2002): No such file or director.md

Warning: mysqli::real_connect(): (HY000/2002): No such file or director

首先确定是mysql_connect()和mysql_pconnect()的问题,故障现象就是函数返回空
而mysql_error()返回No such file or directory写个phpinfo页面,找到mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket

WechatIMG14.jpeg

登录mysql,执行 status命令

Warning: mysqli::real_connect(): (HY000/2002): No such file or director.md_第1张图片
WechatIMG15.jpeg

修改下 sudo vim /etc/php.ini 配置文件

Warning: mysqli::real_connect(): (HY000/2002): No such file or director.md_第2张图片
WechatIMG16.jpeg

重启下sudo /etc/init.d/php-fpm restart 就好了

你可能感兴趣的:(Warning: mysqli::real_connect(): (HY000/2002): No such file or director.md)