2010年2月4日 星期四

MySQL Backup/Restore Large Databases/Tables

To dump large tables, you should combine the --single-transaction option with --quick.

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_quick

--single-transaction
It will allow the live application to use the mysql database as normal without locking any tables and preventing the application to change the database.

In most of case, we have to avoid to use "extended insert" , It will generate too many command line (sql commands)

DO NOT USE "mysqldump --extended-insert", especially huge table!

instead of "mysqldump --extended-insert=FALSE"


MySQL Dump Importer (called BigDump)
http://www.ozerov.de/bigdump.php
In this file, after mysql_connect(), It has to execute "@mysql_query("SET NAMES 'utf8'");" to avoid 亂碼


change the configuration, like below
$linespersession = 600;  // lines per session, It's perhaps to avoid "max_packet_size is too small"
$delaypersession = 6000;  
// how many micro seconds delay after one session

沒有留言:

張貼留言