SYSTEM WARNING: ‘mysql_connect(): No such file or directory’ 和PDOException: SQLSTATE[HY000] [2002] No such file or directory 解决办法

【linux命令】SYSTEM WARNING: ‘mysql_connect(): No such file or directory’ 和PDOException: SQLSTATE[HY000] [2002] No such file or directory 解决办法

今早将阿里云其中一个服务器的mysql升级了下,从mysql 5.1升级到mysql5.7,测试时基本每个项目都报错:
第一个报错:

SYSTEM WARNING: 'mysql_connect(): No such file or directory' in ...

查了下资料,其中通过如下方法解决:
给mysql的sock做一个软链接

ln -s  /tmp/mysql.sock   /data/mysql/mysql.sock

第二个报错:

PDOException: SQLSTATE[HY000] [2002] No such file or directory

查到的解决办法如下:
将配置文件中的localhost改成127.0.0.1解决。

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » SYSTEM WARNING: ‘mysql_connect(): No such file or directory’ 和PDOException: SQLSTATE[HY000] [2002] No such file or directory 解决办法