List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 7 1999 1:01pm
Subject:Re: mysql - Backup
View as plain text  
On Tue, 1999-09-07 20:35:40 +0800, Wee Leng wrote:
> Can I backup/copy database files, even while the database is in
> active?

To prevent that some thread can change a table while the copying
process is still in progress, you have to READ lock the tables.  And
because some data may be cached in memory, you also need to issue
FLUSH TABLES to be sure that all these changes are actually written on
disk.  So what you have to do (within a single connection to MySQL for
not losing the locks) is:

   LOCK TABLES tbl_name READ;
   FLUSH TABLES;
   then copy the table files
   UNLOCK TABLES;

But with these precautions, yes, it does work while the databe is
active.

Regards,
  Martin
--
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
mysql - BackupWee Leng7 Sep
  • Re: mysql - BackupMartin Ramsch7 Sep