hyperf报错:SQLSTATE[HY000] [2002] No such file or directory (SQL: select ...)
一,报错信息:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `news` where `news_id` = 3 limit 1)
sql语句从mysql客户端命令可以正常执行,
判断问题出在数据库的连接上
二,问题原因:
默认数据库连接本地使用了localhost,如下:
DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mybase
解决:
把localhost修改为127.0.0.1
之后查询正常