帮朋友的博客网站从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
问题解决.
新闻热点
疑难解答
图片精选