mysqldump备份数据库

发布时间: 2023-11-21 10:25 阅读: 文章来源:1MUMB20PS

拥有一个自己的网站是一件令人兴奋的事情,不过在运维过程中也会遇到各种各样的小问题,比如今天在备份网站数据库时遇到这样一个错误

mysqldump: Error 1194: Table ‘wp_pkyw_wfhits‘ is marked as crashed and should be repaired when dumping table `wp_pkyw_wfhits` at row: 1245

于是赶紧搜索一番找到解决方法

mysql -uroot -pmysql> use yourdb;mysql> select count(*) from wp_pkyw_wfhits;mysql> desc wp_pkyw_wfhits;+-------------------+-----------------------+------+-----+---------+----------------+| Field | Type| Null | Key | Default | Extra|+-------------------+-----------------------+------+-----+---------+----------------+| id| int unsigned| NO| PRI | NULL| auto_increment || attackLogTime | double(17,6) unsigned | NO| MUL | NULL||| ctime | double(17,6) unsigned | NO| MUL | NULL||| IP| binary(16)| YES| MUL | NULL||| jsRun | tinyint| YES| | 0||| statusCode| int| NO| | 200 ||| isGoogle| tinyint| NO| | NULL||| userID| int unsigned| NO| | NULL||| newVisit| tinyint unsigned| NO| | NULL||| URL| text| YES| | NULL||| referer| text| YES| | NULL||| UA| text| YES| | NULL||| action| varchar(64)| NO| | ||| actionDescription | text| YES| | NULL||| actionData| text| YES| | NULL||+-------------------+-----------------------+------+-----+---------+----------------+15 rows in set (0.00 sec)

原来是WordPress插件Wordfence中的一个表wp_pkyw_wfhits出了问题。

mysql> repair table wp_pkyw_wfhits;+--------------------------+--------+----------+----------+| Table| Op | Msg_type | Msg_text |+--------------------------+--------+----------+----------+| haitaolab.wp_pkyw_wfhits | repair | status| OK|+--------------------------+--------+----------+----------+1 row in set (0.03 sec)

貌似也挺简单的,哈哈。

还有一种使用myisamchk命令的修复方法,不过我没有测试,大家也可以试试

myisamchk -c -r /var/lib/mysql/yourdb/wp_pkyw_wfhits.MYI

其中用到的两个参数的含义:

-c, --check Check table for errors.-r, --recover Can fix almost anything except unique keys that aren‘t unique.
•••展开全文