解决 Can't connect to local MySQL server through socket

[ "\n\t\t\t\t\t", "报错信息:", "\n", "ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)", "\n", "\n使用localhost无法连接MySQL而需要127.0.0.1,原因是连接时候php默认去找 /var/lib/mysql/mysql.sock", "\n", "\n因为MYSQL很多人安装是自己编译安装的,改变了 mysql.sock 的安装位置,或者修改了 /etc/my.cnf 中的:", "\n", "socket = /tmp/mysql.sock", "\n", "\n具体的是mysql的BUG吧,太不智能了。", "\n", "\n所以在连接数据库的时候都要修改一下数据库链接地址:", "\n", "127.0.0.1", "\n\t\t\t\t\t\n\t\t\t\t\t", "\n\t\t\t\t\t\n\t\t\t\t" ]