Recovering MySQL Database from .myd, .myi, .frm Files
If you possess fragmented MySQL database files (.myd, .myi, and .frm), you may encounter the need to restore the database. MyISAM tables can be easily recovered by placing these files in a database directory. This can be done regardless of the initial database, server, MySQL version, or architecture. File ownership may require adjustment using commands like "chown -R mysql:mysql /var/lib/mysql/dbname."
It's important to note that permissions (GRANT, etc.) are stored within the mysql database and will not be restored simultaneously with the tables. Therefore, it may be necessary to manually recreate users and access permissions using appropriate GRANT statements. Alternatively, the mysql database can be restored, but caution should be exercised during MySQL version updates or mysql_upgrade utility executions.
In most cases, the .FRM (structure) and .MYD (data) files suffice; however, the .MYI (indexes) file can be rebuilt via "repair table."
If downgrading, consulting release notes and running "repair table" is highly recommended due to potential feature additions in newer MySQL versions.
It should be emphasized that intermixing tables can compromise relationship integrity. This method is applicable solely to MyISAM tables.
The above is the detailed content of How Can I Recover a MySQL Database from .MYD, .MYI, and .FRM Files?. For more information, please follow other related articles on the PHP Chinese website!