View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 10:25 AM
yankeerivera@yahoo.com
 
Posts: n/a
Default Moving MySQL Files

Hi,

I would apreciate your input on the following solution to the problem
below.

We have a nightly job that takes too long to run. This is mostly
because we have to save our mysql data files (*.MYD and *.MYI) to
another location.

While this takes place, the mysqld process has to be down and we
experience down time. We need to do this at 12AM EST which is a
problem for Tokyo since it is smack during their busy hours.

What if we just renamed the files, put empty ones in their place and
restarted mysqld? That is:

we have these files which are 8GB in total:

~/mysql/data/mydb/XYZ.frm
~/mysql/data/mydb/XYZ.MYD
~/mysql/data/mydb/XYZ.MYI

After shutting down mysql, we could:

# Move the old files out of the way so we can archive them later
mv ~/mysql/data/mydb/XYZ.frm XYZ_old.frm
mv ~/mysql/data/mydb/XYZ.MYD XYZ_old.MYD
mv ~/mysql/data/mydb/XYZ.MYI XYZ_old.MYI

# Copy empty ones in their place so we can start our process
cp ~/mysql/data/mydb/XYZ_emptyShell.frm XYZ.frm
cp ~/mysql/data/mydb/XYZ_emptyShell.MYD XYZ.MYD
cp ~/mysql/data/mydb/XYZ_emptyShell.MYI XYZ.MYI

Start mysqld.

Assume XYZ_emptyShell.* are valid mysql files representing an XYZ
table with 0 rows.

Would mysql complain if we do this to it?

Reply With Quote