mysql报错unix:///var/mysql/mysql.sock

如果mysql连接出现

Warning: mysqli_connect() [function.mysqli-connect]: [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in xxx.php on line 14

查看mysql.sock的位置,一般处于
ls /var/mysql
ls /tmp

默认位于 /var/mysql

sudo vi /etc/php.ini

这里根据你的位置来设置,下面三处都要修改

pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

你可能感兴趣的:(mysql报错unix:///var/mysql/mysql.sock)