Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to recover the .frm file of MyISAM table after it is lost

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the MyISAM table after the loss of .frm file how to recover, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Recovery method after missing .frm file of MyISAM table:

1. Create the experimental MyISAM table T1, and insert the data:

Mysql > create table T1 (id int) engine=myisam

Query OK, 0 rows affected (0.01 sec)

Mysql > insert into T1 values (1), (2), (3), (4), (5), (6), (7), (8)

Query OK, 8 rows affected (0.00 sec)

Records: 8 Duplicates: 0 Warnings: 0

2. Delete the .frm file of the T1 table

[root@localhost gusha] # cd / var/lib/mysql/gusha

[root@localhost gusha] # ls

Db.opt t1.MYI t1.frm t1.MYD

[root@localhost gusha] # rm-rf t1.frm

At this point, the T1 table cannot be queried in the gusha library:

Mysql > show tables

Empty set (0.00 sec)

You can also query the contents of the T1 table because there is a cache, so clear the cache:

Mysql > select * from T1

+-+

| | id |

+-+

| | 1 |

| | 2 |

| | 3 |

| | 4 |

| | 5 |

| | 6 |

| | 7 |

| | 8 |

+-+

8 rows in set (0.00 sec)

Mysql > flush tables

Query OK, 0 rows affected (0.00 sec)

Mysql > select * from T1

ERROR 1146 (42S02): Table 'gusha.t1' doesn't exist

3. Restore and move the t1.MYD and t1.MYI files in the folder corresponding to the gusha library to another folder:

[root@localhost gusha] # mv t1.MY* / var/lib/backup/

[root@localhost gusha] # ls

Db.opt

Recreate a T1 table in the gusha library with the same structure as the original T1 table:

Mysql > create table T1 (id int) engine=myisam

Query OK, 0 rows affected (0.00 sec)

Move the t1.MYD and t1.MYI files to the folder corresponding to the gusha library:

[root@localhost gusha] # mv / var/lib/backup/t1.MY*.

Mv: overwrite `. / t1.MYDuring? Y

Mv: overwrite `. / t1.MYIQUE? Y

At this point, MySQL will automatically repair the T1 table.

Mysql > select * from T1

+-+

| | id |

+-+

| | 1 |

| | 2 |

| | 3 |

| | 4 |

| | 5 |

| | 6 |

| | 7 |

| | 8 |

+-+

8 rows in set (0.00 sec)

If there is no automatic repair, execute the following command to fix it:

Mysql > repair table T1

+-+

| | Table | Op | Msg_type | Msg_text | |

+-+

| | gusha.t1 | repair | status | OK | |

+-+

1 row in set (0.00 sec)

Thank you for reading this article carefully. I hope the article "how to recover after the loss of the .frm file of the MyISAM table" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report