user3578847
user3578847

Reputation: 447

import MYD file into MySQL database

I have the following problem. I have a large .myd backup file which I need to restore. I tried to import it via phpmyadmin and I got syntax errors. As far as I understood it's a binary file and it should 'work' if I put it into the db directory, but it doesn't show up in the database, even when I restart the MySQL server. Any tips how can I import it? Thanks!

Upvotes: 2

Views: 5100

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562240

The .myd file alone is not a backup. It's a copy of MyISAM data for a table, but it's missing the metadata that's stored in the corresponding .FRM file.

You can probably fake-restore your .myd file by using CREATE TABLE to recreate the original table that your data file was associated with. Then shut down mysqld, move your .myd file into place, and restart mysqld. Not that you need to use the exact same CREATE TABLE statement for the column names, positions, and data types for this to work. If you don't remember what those were, you're SOL.

In the future, use a tool like mysqldump or mydumper or Percona XtraBackup to back up databases. Don't just use cp without understanding more about MySQL storage engines.

Upvotes: 3

Related Questions