转自:http://blog.sina.com.cn/s/blog_6f72ff9001018e6l.html
mysql连接时报错:SQLSTATE[HY000] [2002] No such file or directory
设置:
Last login: Fri Aug 15 17:51:49 on ttys001
AndyMacBookPro:~ andy$ sudo find / -name mysql.sock
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/tmp/mysql.sock
AndyMacBookPro:~ andy$ ll /var/mysql
ls: /var/mysql: No such file or directory
AndyMacBookPro:~ andy$ sudo mkdir /var/mysql
AndyMacBookPro:~ andy$ ll /var/mysql/
total 0
drwxr-xr-x 2 root wheel 68 8 15 17:55 ./
drwxr-xr-x 25 root wheel 850 8 15 17:55 ../
AndyMacBookPro:~ andy$ sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
AndyMacBookPro:~ andy$ ll /var/mysql/
total 8
drwxr-xr-x 3 root wheel 102 8 15 17:56 ./
drwxr-xr-x 25 root wheel 850 8 15 17:55 ../
lrwxr-xr-x 1 root wheel 23 8 15 17:56 mysql.sock@ -> /private/tmp/mysql.sock
AndyMacBookPro:~ andy$
之后就好了:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
换成其他报错了~~