mysqldump 报错 Got error: 145


当用 mysqldump 备份 MySQL 或 MariaDB 数据库时, 如果出现类似以下报错:

mysqldump: Got error: 145: Table ‘[table-name]’ is marked as crashed and should be repaired when using LOCK TABLES

出现这个错误, 是资料表出现损坏, 可以尝试用 MySQL 的 repair table 语法修复:

mysql -u root -p

输入 root 的密码后, 先选用损坏资料表所属的数据库:

mysql> use database-name;
mysql> repair table table-name;
mysql> exit;

除了在指令模式登入 mysql 外, 用 phpMyAdmin 直接输入 repair table 也可以。

执行完 repair table 后, 再次尝试用 mysqldump 备份, 一般应该没有问题的。

Tags:

Leave a Reply