Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Restoring MyISAM Tables from FRM, MYD, and MYI Files in MySQL 5.7

Tech Jul 23 5

Procedure Overview

PhaseAction
1Authenticate with the database server
2Provision a new schema
3Position raw files into the data directory
4Reconcile table metadata and indexes

Phase 1: Authenticate with the database server

Establish a connection to the MySQL instance using administrative credentials:

mysql -h localhost -u admin_user -p

The -p flag triggers a secure password prompt.

Phase 2: Provision a new schema

Instantiate a database container for the target data:

CREATE DATABASE restored_db CHARACTER SET utf8mb4;
USE restored_db;

Phase 3: Position raw files into the data directory

Locate the MySQL data storage path and transfer the backup files (.frm, .MYD, .MYI) into the newly created schema directory. Execute these commands in the system terminal:

sudo cp /path/to/backup/target_table.frm /var/lib/mysql/restored_db/
sudo cp /path/to/backup/target_table.MYD /var/lib/mysql/restored_db/
sudo cp /path/to/backup/target_table.MYI /var/lib/mysql/restored_db/
sudo chown mysql:mysql /var/lib/mysql/restored_db/target_table.*

Adjusting file ownership ensures the MySQL daemon has read/write permissions.

Phase 4: Reconcile table metadata and indexes

Return to the MySQL shell and force the server to recognize the newly placed files and validate their structural integrity:

REPAIR TABLE restored_db.target_table USE_FRM;

This operation reconstructs the index information from the .frm and .MYD files if the .MYI file is corrupted, bringing the table online.

Tags: MySQL

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.