當前位置: 首頁>>技術問答>>正文


WordPress數據庫錯誤:Lost connection to MySQL server

問題描述:

 

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 ~]#

 

 

 

 

本文由《純淨天空》出品。文章地址: https://vimsky.com/zh-tw/article/1959.html,未經允許,請勿轉載。