[WordPress] Error establishing a database connection的解决方法
转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]
本文链接: http://www.php-oa.com/2010/08/12/wordpresserror-establishing-a-database-connection.html
这几天老发现自己的网站出现 Error establishing a database connection .但实际压力不大,连接很少.平时重起 MySql 也就好了.这次怎么重启都不行.
只好静下来看看为什么.平时正常,现在不正常,配置文件一定是没有问题.所以,只能从别的方面查原因.发现进入 wp-admin 后提示我
One or more database tables are unavailable. The database may need to be repaired.
然后让我添加
define('WP_ALLOW_REPAIR', 'true');
到 wp-config.php,然后在次刷新 wp-admin 来修复.但加入后,怎么点修复,还是没有反应.结果没变,还是出现 Error establishing a database connection.
后来发现在 wp-config.php 有个 debug 的参数,打开这个参数,修改为:
define('WP_DEBUG', 'true');
修改这个后,非常不错,报了很多错,一堆….
WordPress database error: [Table './phpoa/wp_options' is marked as crashed and should be repaired]
SELECT autoload FROM wp_options WHERE option_name = '_transient_doing_cron'
WordPress database error: [Table './phpoa/wp_options' is marked as crashed and should be repaired]
SELECT autoload FROM wp_options WHERE option_name = '_transient_timeout_doing_cron'
WordPress database error: [Table './phpoa/wp_options' is marked as crashed and should be repaired]
SELECT option_value FROM wp_options WHERE option_name = '_transient_doing_cron' LIMIT 1
发现都是 wp_options 表的错,看来这个表坏了,使用 mysql 的客户端.连接进 mysql 使用修复的命令来修复.
mysql>repair table wp_options;
搞定,然后关掉 DEBUG,解决问题.
在一次出现这个问题….
这次是 wp_options 真的坏了…..只能恢复才行.怎么查啦,花了很久的时间来定位.
后来直接打开 mysql 的日志,对比别人的,才查出原因
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
## clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
max_connections = 500 #增加mysql连接数
wait_timeout = 10 #断开超过10秒的连接# symbolic-links=0
log-error=/var/log/mysqld.log
log=/var/log/mysqld.log
后看是那句出错,没有值.才查出原因



















原来mysql有个repair命令的啊
@流年
我记得phpmyadmin这个客户端里有修复选项
不过还不知道如何用mysql命令来修复呢
这两天我的博客老是出现,我擦!
我的貌似是连接数太少的问题,我找不到空间提供商
不错!!刚好遇到此问题~~呵~~