views:

45

answers:

4

Which files are the actual files holding the data in the tables in a mysql db?

I went to /var/lib/mysql/ and I can see there a bunch of relatively small directories corresponding to my tables, and a lot of files named servername-bin.0000001 etc.

Is the data stored in those files?

A: 

It is stored in various files under that directory, yes. The exact files used depends on what engine the tables are using.

Ignacio Vazquez-Abrams
Can you be more specific if I tell it's innodb?
noam
A: 

a bunch of relatively small directories corresponding to my tables

Not a tables but databases

servername-bin.0000001

that's binary logs, it has nothing to do with data

why do you need to know, by the way?

Col. Shrapnel
+1  A: 

Check out the ibdata1 file and its ilk.

From the documentation:

"Two important disk-based resources managed by the InnoDB storage engine are its tablespace data files and its log files. If you specify no InnoDB configuration options, MySQL creates an auto-extending 10MB data file named ibdata1 and two 5MB log files named ib_logfile0 and ib_logfile1 in the MySQL data directory. To get good performance, you should explicitly provide InnoDB parameters as discussed in the following examples. Naturally, you should edit the settings to suit your hardware and requirements."

janmoesen
Also see http://dev.mysql.com/doc/refman/5.1/en/multiple-tablespaces.html if you are trying to recover disk space after dropping tables.
janmoesen
+3  A: 

It is installation specific, but if you've /var/lib/mysql , then:

  • MyISAM tables will be stored in individual files in /var/lib/mysql/databasename/
  • InnoDB resides in /var/lib/mysql/ibdata (unless you've used the innodb_per_table setting, in which case it's stored much like for MyISAM tables)
nos