不用担心,一步步尝试,最终问题都会搞定。
我仔细回忆了前前后后,发现我应该是没有修改任何内容。因为之前都是配置了系统启动项,PHP/MySQL 服务都是自动开启的,WordPress 的数据库链接配置,一直都没有修改过。
先检查 PHP/MySQL 服务状态,端口开启情况。
核对过,没有任何问题。
核对数据库的用户名和密码,是否可以登录。
核对过,数据库用户名和密码都没有变化。
核对 wp-config.php 文件中数据库参数配置。
WordPress 中的 wp-config.php 文件中数据库参数配置都正常。
那究竟是哪里出了问题,以前的数据是否还在?
核对之前的数据备份和服务器磁盘快照。
我的服务器是使用的腾讯云,上一次手动制作服务器磁盘快照还是在今年年初二月份,看来不是很好,而自动周期性备份也是在昨天,我先将服务器系统盘和数据盘回退到此服务器磁盘快照。然后同时对当前节点做一个磁盘快照制作。
服务器上导出数据库看是否还存在。
当我想要导出数据库的时候,就提示:导出数据库(wordpress)失败:mysqldump: Couldn’t execute ‘show create table `wp_options`’: Table ‘./wordpress/wp_options’ is marked as crashed and should be repaired (145)。一旦出现明确的错误提醒的时候,就是解决问题的开始。
通过 Google 查询,可以通过 MySQL 命令行查询数据库状态,如果有问题的话,可以尝试用命令行进行修复。
核对 WordPress 环境
CentOS 6.6 WordPress 4.5.28 PHP 5.6.24 MySQL 5.5.50
通过使用以下 MySQL 命令检查 MySQL 数据库状态//wordpress 是 WordPress 数据库名 mysqlcheck -u root -p wordpress //然后输入 wordpress 数据库密码
得到的结果:# mysqlcheck -u root -p wordpress Enter password: wordpress.wp_bwg_album OK wordpress.wp_bwg_album_gallery OK wordpress.wp_bwg_file_paths OK wordpress.wp_bwg_gallery OK wordpress.wp_bwg_image OK wordpress.wp_bwg_image_comment OK wordpress.wp_bwg_image_rate OK wordpress.wp_bwg_image_tag OK wordpress.wp_bwg_shortcode OK wordpress.wp_bwg_theme OK wordpress.wp_commentmeta warning : 9 clients are using or haven't closed the table properly status : OK wordpress.wp_comments warning : 7 clients are using or haven't closed the table properly status : OK wordpress.wp_cptch_images OK wordpress.wp_cptch_packages OK wordpress.wp_cptch_whitelist OK wordpress.wp_links OK wordpress.wp_ngg_album OK wordpress.wp_ngg_gallery OK wordpress.wp_ngg_pictures OK wordpress.wp_options warning : Table is marked as crashed warning : 53 clients are using or haven't closed the table properly error : Record at pos: 488396 is not remove-marked error : record delete-link-chain corrupted error : Corrupt wordpress.wp_postmeta warning : 53 clients are using or haven't closed the table properly status : OK wordpress.wp_posts warning : 32 clients are using or haven't closed the table properly status : OK wordpress.wp_sbi_instagram_feed_locator OK wordpress.wp_sbi_instagram_feeds_posts OK wordpress.wp_sbi_instagram_posts OK wordpress.wp_smush_dir_images OK wordpress.wp_term_relationships warning : 12 clients are using or haven't closed the table properly status : OK wordpress.wp_term_taxonomy warning : 9 clients are using or haven't closed the table properly status : OK wordpress.wp_termmeta OK wordpress.wp_terms warning : 2 clients are using or haven't closed the table properly status : OK wordpress.wp_usermeta warning : 16 clients are using or haven't closed the table properly status : OK wordpress.wp_users warning : 1 client is using or hasn't closed the table properly status : OK
通过使用以下 MySQL 命令修复 MySQL 数据库//wordpress 是 WordPress 数据库名 mysqlcheck -u root -p wordpress --auto-repair //然后输入 wordpress 数据库密码
得到的结果:# mysqlcheck -u root -p wordpress --auto-repair Enter password: wordpress.wp_bwg_album OK wordpress.wp_bwg_album_gallery OK wordpress.wp_bwg_file_paths OK wordpress.wp_bwg_gallery OK wordpress.wp_bwg_image OK wordpress.wp_bwg_image_comment OK wordpress.wp_bwg_image_rate OK wordpress.wp_bwg_image_tag OK wordpress.wp_bwg_shortcode OK wordpress.wp_bwg_theme OK wordpress.wp_commentmeta OK wordpress.wp_comments OK wordpress.wp_cptch_images OK wordpress.wp_cptch_packages OK wordpress.wp_cptch_whitelist OK wordpress.wp_links OK wordpress.wp_ngg_album OK wordpress.wp_ngg_gallery OK wordpress.wp_ngg_pictures OK wordpress.wp_options warning : Table is marked as crashed warning : 53 clients are using or haven't closed the table properly error : Record at pos: 488396 is not remove-marked error : record delete-link-chain corrupted error : Corrupt wordpress.wp_postmeta OK wordpress.wp_posts OK wordpress.wp_sbi_instagram_feed_locator OK wordpress.wp_sbi_instagram_feeds_posts OK wordpress.wp_sbi_instagram_posts OK wordpress.wp_smush_dir_images OK wordpress.wp_term_relationships OK wordpress.wp_term_taxonomy OK wordpress.wp_termmeta OK wordpress.wp_terms OK wordpress.wp_usermeta OK wordpress.wp_users OK Repairing tables wordpress.wp_options warning : Number of rows changed from 501 to 502 status : OK
然后重启 MySQL 服务,问题解决啦!上一篇: « 网站内容导航 下一篇: 深圳拾年 »
我以前以为,只要 WordPress 中的 PHP 正确链接上了 MySQL 数据库,系统开机自动启动相关的服务,然后正常的开关机服务器,就不会对 MySQL 数据库有影响,但是经过这次经验之后,发现一些特殊情况下,数据库是可能会被损坏的,但是可以通过自动修复来恢复。