错误 mysqli::real_connect(): (HY000/2002): No such file or directory

这个错误是由于无法找到 mysql.sock 文件

启动mysql服务并查看mysql的socket路径

可以通过mysql命令行 STATUS;

查看php.ini文件中

pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket=/tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

这三个参数的值是否和mysql的socket值一致,不一致就需要修改成一致

时间: 2024-12-26 21:23:51

错误 mysqli::real_connect(): (HY000/2002): No such file or directory的相关文章

mac 连接mysql提示 Warning: mysqli::real_connect(): (HY000/2002): No such file or directory

mac 连接mysql的时候提示 Warning: mysqli::real_connect(): (HY000/2002): No such file or directory [说明1]MAC下MYSQL的安装路径:/usr/local/mysql-5.5.28-osx10.6-x86 数据库的数据文件在该目录的data文件夹中: 命令文件在bin文件夹中. [说明2]通过终端打开MYSQL命令行的方法:/usr/local/mysql-5.5.28-osx10.6-x86/bin/mysq

phpmyadmin提示mysqli_real_connect(): (HY000/2002): No such file or directory错误的解决办法

phpmyadmin上传到网站目录后提示解决phpmyadmin mysqli_real_connect(): (HY000/2002): No such file or directory的错误,解决方法把phpmyadmin目录中的配置文件config.sample.inc.php改成config.inc.php 打开编辑config.inc.php 找到: $cfg['Servers'][$i]['host'] = 'localhost'; 改成: $cfg['Servers'][$i][

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory解决方法

今天用pdo连接mysql遇到一个奇怪的问题,host设为127.0.0.1可以连接成功,设为localhost就会报如下的错误: PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/share/nginx/html/test.php:2 Stack trace: #0 /usr/share/nginx

laravel 报错SQLSTATE[HY000] [2002] No such file or directory

在mac中执行php artisan migrate时报错 SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = weifenxiao and table_name = migrations) [PDOException] SQLSTATE[HY000] [2002] No such file or directory

TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory

连接数据库报错:“SQLSTATE[HY000] [2002] No such file or directory”. 出现这个问题的原因是PDO无法找到mysql.sock或者mysqld.sock.  解决方法1:找到相应的.sock文件,并设置php.ini文件中的pdo_mysql.default_socket的值为.sock文件的路径. pdo_mysql.default_socket= /tmp/mysqld.sock 然后重启Apache,或者nginx下重启php-fpm即可.

YII 错误 SQLSTATE[HY000] [2002] No such file or directory

在使用yii的yii\db\Connnection时发生错误 <?php namespace app\controllers; use yii\web\Controller; use yii\db\Connection; use Yii; class MyController extends Controller { public function actionIndex() { $country = Yii::$app -> db -> createCommand("sele

PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory

错误环境:Mac OS 10.10 找到mysql.sock文件的位置 $sudo find / -name mysql.sock ------结果如下---------- find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory /private/tmp/mysql.sock 检查/var/mysql是否存在 $ll /var/mysql 如果/var/mysql不存在则创建 $sudo mkdir /var/mysql

thinkphp 数据库连接报错 SQLSTATE[HY000] [2002] No such file or directory

https://blog.csdn.net/tornge/article/details/51388233 找到mysql sokcet的路径 vim /etc/mysql/mysql.conf.d/mysqld.cnf socket = /var/run/mysqld/mysqld.sock 在php.ini中关于mysql的socket路径的地方,修改如如下 [Pdo_mysql] ; If mysqlnd is used: Number of cache slots for the int

YII2数据库操作出现类似Database Exception – yii\db\Exception SQLSTATE[HY000] [2002] No such file or director

YII2进行MYSQL数据库操作时出现Database Exception – yii\db\Exception  SQLSTATE[HY000] [2002] No such file or directory错误的解决方法 在进行数据库操作时出现如下类似错误,实际则是PHP配置文件php.ini中未指定mysql.sock(或mysqld.sock)文件路径导致的PDO无法链接数据库 Database Exception – yii\db\Exception SQLSTATE[HY000]