200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > mysql数据库myd文件丢失怎么_mysql数据库的恢复(frm Myd MyI文件仍存在)

mysql数据库myd文件丢失怎么_mysql数据库的恢复(frm Myd MyI文件仍存在)

时间:2018-11-12 10:54:03

相关推荐

mysql数据库myd文件丢失怎么_mysql数据库的恢复(frm Myd MyI文件仍存在)

问题背景:

服务器被攻击,数据库A被删!

目前进展:

1.用恢复软件把数据库A中的frm、Myd、MyI文件进行还原,但访问数据库时,则提示Incorrect information in file

2.浏览数据库时发现有几张表提示使用中,从而不能正常访问与操作表

问题:

如何在保证不丢失数据的前提下,可以正常访问数据库

自己尝试过的办法:

1.使用repire table ,这时就可以操作表了,可是数据全没了!

2.其中myd与myi文件的大小均大于0,推测不是索引损坏而导致的问题

A very important database has gone corrupt that was sitting on server at a shared web host, and I didn't back up. The table contains a large list of very important email addresses. I can get a table listing, but if I open any of the tables with Navicat or phpMyAdmin, I get the following error:

Incorrect information in file: './the-table-name.frm'

I was able to get a hold of the .frm files associated with the database from the web host.

There is other data in there, but if I could at least get the email addresses, I would be alright.

How do I recover this database? I would be willing to pay somebody to fix this.

*************************************************************

This belongs on serverfault.

First, .FRM files contain none of your "data". They are simply the definition of the table.

If all of the following are true:

The table is using the MyISAM storage engine

You know the CREATE TABLE statement required to recreate the table

Then, do the following:

Stop MySQL

Backup your table_name.frm, table_name.MYI, table_name.MYD files

Delete them from your mysql data directory (/var/lib/mysql usually)

Start MySQL

CREATE the table again

Stop MySQL

Copy the .MYD and .MYI files back into the datadir, replacing the ones there.

Start MySQL

???

Profit

以上是国外一个网站的方法,上文作者利用此方法恢复了数据。查了一下这几种文件的含义:

首先说一下这几种文件是干什么的,*.frm是描述了表的结构,*.MYD保存了表的数据记录,*.MYI则是表的索引

表 MySQL文件类型

-----------------------------------------------------------------

文件类型 文件名扩展名 文件内容

样式文件 .frm 描述表的结构(它的列、列类型、索引等)。

数据文件 .ISD(ISAM)

或.MYD(MyISAM) 包含数据文件上的所有索引的索引树。

索引文件 .ISM(ISAM)

或.MYI(MyISAM) 该索引文件依赖表是否有索引而存在。

---------------------------------------------------------------

当你发出一条CREATE TABLE tbl_name时语句定义表的结构时,服务器创建一个名为tbl_name.frm的文件,它包括该结构的内部编码,同时也创建一个空数据和索引文件,初始化为包含指出无记录和无索引的信息(如果CREATE TABLE语句包括索引指定,索引文件反映出这些索引)。对应于表的文件的属主和模式被设置为只允许MySQL服务器用户访问。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。