Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

24.2. SQLSTATE[HY000] [2002] No such file or directory

查看 mysql unix_socket 地址

		
mysql> show variables like '%socket%';
+-----------------------------------------+---------------------------+
| Variable_name                           | Value                     |
+-----------------------------------------+---------------------------+
| performance_schema_max_socket_classes   | 10                        |
| performance_schema_max_socket_instances | -1                        |
| socket                                  | /var/lib/mysql/mysql.sock |
+-----------------------------------------+---------------------------+
3 rows in set (0.02 sec)
		
		

查看 php.ini 中的 pdo_mysql.default_socket 配置

		
# php -i | grep pdo_mysql.default_socket
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
		
		

打開php.ini檔案將 pdo_mysql.default_socket 配置為 /var/lib/mysql/mysql.sock

重啟 php-fpm 後配置生效

systemctl restart php-fpm