Can't connect to local MySQL server through socket '/usr/local/mysql/mysql.sock' 如何解决
mysql.sock 是本地通讯用的 unix socket file,具体位置取决于 mysql 的安装。如楼上所说,把 host 改了就可以用过 tcp/ip 连接了。
试试用 lsof 找出 socket file
$ ps -A | grep mysql 2024 s002 S 0:49.38 /usr/local/Cellar/mysql/5.5.10/bin/mysqld $ lsof -p 2024 # output omitted # Bingo! mysqld 2024 howard 12u unix 0x08a70870 0t0 /tmp/mysql.sock mysqld 2024 howard 13u REG 14,2 2048 1013034 /usr/local/var/mysql/mysql/host.MYI mysqld 2024 howard 14u REG 14,2 0 1013035 /usr/local/var/mysql/mysql/host.MYD mysqld 2024 howard 15u REG 14,2 2048 1013037 /usr/local/var/mysql/mysql/user.MYI mysqld 2024 howard 16u REG 14,2 736 1013038 /usr/local/var/mysql/mysql/user.MYD mysqld 2024 howard 17u REG 14,2 5120 1013030 /usr/local/var/mysql/mysql/db.MYI mysqld 2024 howard 18u REG 14,2 3080 1013032 /usr/local/var/mysql/mysql/db.MYD
WINDOWS 也有 socket Windows SOCKET 编程 http://wenku.baidu.com/view/1f27acf5f61fb7360b4c65e4.html
别把 SOCKET 跟 TCP/IP 搞混了,两者完全不是一个概念,虽然实现了同样的连接。