幫朋友的博客網站從apache 換成 nginx 之后wordpress 出錯提示 “建立數據庫連接時出錯”.
而apache 是可以正常連接,本地mysql 也可以正常登錄上去.
1、使用 mysql -uroot -p 登錄上mysql 并用 show variables like ‘socket'; 查詢mysql socket的文件存在什么地方,代碼如下:
- [root@iZ23482kqn1Z default]# mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or /g.
- Your MySQL connection id is 18509
- Server version: 5.1.73 MySQL Community Server (GPL)
- Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
- mysql> show variables like 'socket';
- +---------------+-----------------+
- | Variable_name | Value |
- +---------------+-----------------+
- | socket | /tmp/mysql.sock |
- +---------------+-----------------+
- 1 row in set (0.00 sec)
2、編輯 /etc/php.ini 文件找到 mysql.default_socket =,修改成以下代碼:
- ; Default socket name for local MySQL connects. If empty, uses the built-in
- ; MySQL defaults.
- ; http://php.net/mysql.default-socket
- --Vevb.com
- mysql.default_socket =/tmp/mysql.sock
3、重起php-fpm 服務
service php-fpm restart
問題解決.
新聞熱點
疑難解答
圖片精選