[WordPress] Error establishing a database connection的解决方法

Aug 12th, 2010

转载本站文章请注明,转载自:扶凯[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

后看是那句出错,没有值.才查出原因

 

 

 

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪 ViVi 365Key 网摘 天极网摘 和讯网摘 博拉网 POCO 网摘 饭否 QQ 书签 Digbuzz 我挖网 Mister Wong
  1. 流年
    Aug 13th, 2010 at 00:11
    Reply | Quote | #1

    原来mysql有个repair命令的啊

  2. blinux
    Aug 29th, 2010 at 21:36
    Reply | Quote | #2

    @流年
    我记得phpmyadmin这个客户端里有修复选项
    不过还不知道如何用mysql命令来修复呢 :grin:

  3. joyla
    Sep 21st, 2010 at 18:11
    Reply | Quote | #3

    这两天我的博客老是出现,我擦!

  4. IT不倒翁
    Oct 1st, 2010 at 20:48
    Reply | Quote | #4

    我的貌似是连接数太少的问题,我找不到空间提供商 :cry:

  5. xzl
    Nov 22nd, 2010 at 02:03
    Reply | Quote | #5

    不错!!刚好遇到此问题~~呵~~