问题描述:
PHP message: WordPress数据库 xxx… 发生 Lost connection to MySQL server during query错误,这是由 xxx ….。
其他表现,访问网页时提示: 建立数据库连接时出错 。
问题原因:
通常是因为数据库软件跟数据库本身版本不匹配导致,比如数据库软件升级,或者数据库迁移,这时候,某些表结构发生变化,从而导致访问数据库出错。
打开/var/lib/mysql/xxx.err文件,通常会发现如下内容:
[ERROR] mysqld: Table './dbname/wp_options' is marked as crashed and should be repaired [Warning] Checking table: './dbname/wp_options' [ERROR] mysqld: Table './dbname/wp_users' is marked as crashed and should be repaired [Warning] Checking table: './dbname/wp_users' 。。。。。
解决方案:
解决方案通常是通过mysql_upgrade检查修复数据库中的表。示例如下:
[root@vimsky ~]# mysql_upgrade -u root -p
Enter password:
Phase 1/4: Fixing views
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables Processing databases information_schema mywordpressblogsDB
mywordpressblogsDB.wp_commentmeta OK
mywordpressblogsDB.wp_comments OK
mywordpressblogsDB.wp_cptch_images OK
mywordpressblogsDB.wp_cptch_packages OK
mywordpressblogsDB.wp_cptch_whitelist OK
mywordpressblogsDB.wp_gravatars OK
mywordpressblogsDB.wp_links OK
mywordpressblogsDB.wp_options OK
mywordpressblogsDB.wp_postmeta OK
mywordpressblogsDB.wp_posts OK
mywordpressblogsDB.wp_supsystic_tbl_columns OK
mywordpressblogsDB.wp_supsystic_tbl_diagrams OK
mywordpressblogsDB.wp_supsystic_tbl_rows OK
mywordpressblogsDB.wp_supsystic_tbl_tables OK
mywordpressblogsDB.wp_term_relationships OK
mywordpressblogsDB.wp_term_taxonomy OK
mywordpressblogsDB.wp_termmeta OK
mywordpressblogsDB.wp_terms OK
mywordpressblogsDB.wp_usermeta OK
mywordpressblogsDB.wp_users OK
mywordpressblogsDB.wp_wp_rp_tags OK
mysql mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.servers OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
performance_schema test Phase 4/4: Running 'mysql_fix_privilege_tables' OK
[root@vimsky ~]#
|