当前位置: 代码迷 >> 综合 >> laravel SQLSTATE[HY000] [2002] No such file or directory
  详细解决方案

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

热度:81   发布时间:2023-12-14 11:29:58.0

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

需要在mysql中执行:show variables like '%sock%'

这里值为/tmp/mysql.sock

将socket的value值写入.env中,

增加DB_SOCKET=/tmp/mysql.sock,

config/database.php,connections的mysql下增加'unix_socket' => env('DB_SOCKET', ''),

清缓存:

php artisan view:clear

php artisan config:cache

php artisan cache:clear

增加了还报错,或者修改了mysql的配置但是依旧不生效的话,删除bootstrap/cache的缓存文件!!!

  相关解决方案