SQLSTATE[HY000] [2002] No such file or directory mysql 连接时出现 SQLSTATE[HY000] [2002] No such file or directory 错误,解决办法:将连接时使用的 localhost 改为 127.0.0.1 即可。