linux mysql 修复表,如何在mysql中修复或删除/创建损坏的表?

情况:我有一个包含104个表的MySQL数据库,在Windows 7上的XAMPP上本地运行.所有表都有InnoDB引擎. XAMPP MySQL作为Windows服务运行.作为前端我有PHP(CodeIgniter).

问题:昨晚像往常一样,我停止了项目工作并正常关闭窗户.今天早上我得到错误表MY_TALBE在浏览器中不存在.控制台上的show tables显示表名,但是desc MY_TABLE并从MY_TABLE中选择*表示未知表.我尝试创建表MY_TABLE(…)但我有错误,因为表MY_TABLE已经存在,所以我尝试删除表MY_TABLE但它说未知表MY_TABLE!我尝试使用mysqlcheck.exe进行修复和检查,但两者都失败了,但之后,show tables不再显示表名.我需要提一下我没有更改/移动/删除/重命名任何mysql文件.

问题:是否有可能恢复/修复MY_TABLE,或至少如何删除并再次创建它(不丢弃数据库并再次重新启动它)?

解决方法:

首先,这是InnoDB架构

在那篇文章中,我基本上指出表的元数据仍然存在于系统表空间文件ibdata1中.

当你运行SHOW TABLES;时,所有mysqld都报告了.frm文件.可以将表创建为MyISAM,因为它没有附加到ibdata1或任何其他元数据.但是,您无法将其转换为InnoDB,因为元数据会以某种方式想象.frm和一些tablespace_id附加到表名.基于我的旧帖子,我只是mysqldump所有其他表,并称你的表是一个失败的原因.但是,Percona has the Data Recovery Toolkit就是这样的场合.

The Percona Data Recovery Tool for InnoDB is a free toolkit for recovering lost or corrupted data from InnoDB tables. It provides a way to extract InnoDB’s data from files or raw devices in a tab-separated format when standard InnoDB recovery cannot be used for some reason such as a dropped table or severe corruption that prevents InnoDB from recognizing the data. It can be used for MySQL recovery to retrieve deleted tables, recover previous versions of updated rows, or fix InnoDB file corruption after a hardware failure such as a memory fault or bad cabling.

Percona has used these tools to perform MySQL data recovery for many customers, including extremely large datasets. Although the tools are powerful, performing InnoDB data recovery correctly requires expert knowledge of the InnoDB storage format and source code plus experience, and intuition. Percona can help with our data recovery service.

我没有用它,但如果Percona做到了,你应该试一试.

如果你有丢失的表的备份(以mysqldump的形式),你应该从我的旧帖子执行步骤,然后加载丢失的表的备份.

建议

一旦你摆脱了这种情况,你应该调整InnoDB来刷新磁盘更改.

[mysqld]

innodb_fast_shutdown=0

innodb_max_dirty_pages_pct=0

innodb_buffer_pool_dump_at_shutdown=1

innodb_buffer_pool_load_at_startup=1

这样,当您关闭mysql时,InnoDB可以更彻底地刷新更改.

如果你想要更好地保证InnoDB被刷新到磁盘,你应该在Linux中使用MySQL.

标签:recovery,mysql,innodb

来源: https://codeday.me/bug/20190806/1597427.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值