PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
将mysql.sock文件映射到/var/mysql路径中
$sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
重新刷新错误页面......
以上是关于PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory的主要内容,如果未能解决你的问题,请参考以下文章
TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory
PHP PDO连接SQLSERVER报错:SQLSTATE[08001]: [Microsoft][SQL Server Native Client 10.0]TCP Provider
PHP + MYSQL + Laravel - “SQLSTATE [HY000] [2002] 连接被拒绝” [重复]
PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknow.....
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
PHP错误:SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client