Sunday, November 11, 2007

MySQL Fatal Error Maximum Execution Time Exceeded

I was trying to backup a database containing +/- 2,2 millions record from one host (Ubuntu 7.10 running MySQL 5.0.45) and restore to another host (Windows XP running MySQL 5.0.0alpha).

I ran "mysqldump -user=wahyu -p aida32wyu > aida32wyu.sql", where aida32wyu being the database name, copy the result (aida32wyu.sql) to target machine and execute "source d:\aida32wyu.sql" from mysql console just to get "Fatal Error: Maximum execution time 300 seconds exceeded".

I thought something was wrong with the mysql in the target machine, like too short execution time or whatever option it has right inside my.cnf or elsewhere. But I found none of them. Googling also yielded things people refer to as problem inherent with PHP setting itself, but I didn't use any PHP so it must have been something else.

Still, I insisted the problem was on the restoring process, until I found out that the restoring process always halt after the same records and finally confirmed by using "tail aida32wyu.sql" that it was the mysqldump containing exactly the line "Fatal Error ..." that breaks the SQL syntax.

Then I focused on mysqldump. I wanted to know if it has some command-line options to indicate maximum execution time but none found. An interesting thing happen suddenly when I figured out from the "mysqldump --help" that we should disable --opt option (by --skip-opt) to dump SQL to be restored to older version of MySQL.

Voila! I ran
"mysqldump --skip-opt --port=3306 -p user=wahyu -v aida32wyu > aida32wyu.sql"
and didn't find any "Fatal Error" anywhere in the result. Restoring the SQL to my target machine was normal. No sweat.

No comments: