Where are my .myd, .myi and .frm files from my mysql database

3.7k Views Asked by At

I'm a beginner here and I can't seem to find the files. My professor wants me to send these files specifically to her, but when I "export data" from the workbench, it only generates .sql files. Where do I get the .myd, .myi and .frm files she's looking for.

Thank you

2

There are 2 best solutions below

2
user207421 On BEST ANSWER

Somewhere there is a data directory under a directory with MySQL in the filename, and under data is your own database directory. Files are in there. But if you haven't used MyISAM as the table format, the files will have different extensions, e.g. .idb for InnoDB.

You can find it via the query mentioned in @tadman's comment, or from a shell:

find / -name data -print

although you will probably get a number of matches.

You will have to stop the MySQL server before you can copy the files.

6
tadman On

Don't worry about those. That's just how MySQL stores the data internally. If you read the documentation carefully you'll soon learn that you shouldn't depend on those files for backups anyway, they're likely to be in an inconsistent state if the server's running.

The best way to make a backup for small to medium-sized databases is the mysqldump command. There's a number of options that can be applied but the most important on a busy database is --single-transaction which produces a consistent point-in-time snapshot.

The SQL data you get from that, which can be saved to a .sql file, is sufficient to recreate the database and is a backup.

You can restore with the mysql command-line tool, or if you're not comfortable with that, the MySQL Workbench program.