18739325251
您的当前位置:主页 > 知识博客 > Laravel开发 >

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

时间:2018-07-06

在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

这个是由于找不到mysql.sock文件造成的

1.在MySQL里面执行sql语句 show variables like '%sock%'

2.对应返回的结果的字段 socket 的对应的value,一般的结果大概长这个样子 /tmp/mysql.sock

3.修改文件 ./config/database.php 中的 connections 下的 mysql 添加

‘unix_socket’ => ‘/tmp/mysql.sock’

这样就可以执行了

技术支持:卓微网络科技 Copyright © 2015-2019 www.vrzytt.com 卓微科技 版权所有 豫ICP备16026818号-1