Home >Database >Mysql Tutorial >How to Recover a MySQL Database from .myd, .myi, and .frm Files?

How to Recover a MySQL Database from .myd, .myi, and .frm Files?

Susan Sarandon
Susan SarandonOriginal
2024-12-10 17:30:12922browse

How to Recover a MySQL Database from .myd, .myi, and .frm Files?

Data Recovery from MySQL Table Fragments

Question:

How can you restore a MySQL database using only its .myd, .myi, and .frm files?

Answer:

For MyISAM tables, recovering data from these files is straightforward:

  • Copy the files to a database directory: Place the .frm, .myd, and .myi files in the desired database directory (e.g., /var/lib/mysql/dbname).
  • Set ownership: Change ownership of the directory to mysql:mysql (e.g., chown -R mysql:mysql /var/lib/mysql/dbname).
  • Database mismatch: The files can be restored to a different database, server, MySQL version, or architecture.
  • Permissions: Permissions are not restored with the tables, so you may need to run GRANT statements to recreate user access.
  • Repair table: While you typically only need the .frm and .myd files, repairing the table will rebuild the .myi (indexes) file.
  • Compatibility: Ensure the MySQL version you're restoring to is compatible with the files' version.
  • Table relationships: Restoring multiple tables may disrupt their relationships if the data was mixed and matched.
  • InnoDB tables: This method does not work for InnoDB tables.

The above is the detailed content of How to Recover a MySQL Database from .myd, .myi, and .frm Files?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn