MySQL Maximum execution time of 300 seconds exceeded in command line – tips

Have you been working with large MySQL databases?
Have you just performed a database export to a file from a web interface such as phpMyAdmin and attempted to import it elsewhere via a command line similar to the below?

mysql -u USER -p DBNAME < dump.sql

I came across the following issue where I kept getting this error message:

Fatal error: Maximum execution time of 300 seconds exceeded in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/dbi/mysql.dbi.lib.php on line 229

The reason for this is due to the source’s PHP export script timing out from its max_execution_time setting.

To resolve this, either use a command line to perform the export or if you have SSH access on your server or split the export into several stages. I’ve had to split my export into two lots to get the timeout under 300 seconds which was the shared cPanel server’s max limit.

Comments (2)

  • David Majidian says:

    Why did you not change the time limit in your script (or php.ini)?

    set_time_limit(0);
    ini_set(‘max_execution_time’, 0);

  • Peter says:

    You are correct. The command you mentioned will do the trick.

    My host had limitations of altering the max_execution_time at the time of writing.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.