首页 > 代码库 > PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory

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 directoryfind: /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