How To Extend Max Execution Time in XAMPP
Extending Max Execution Time
I recently ran into an issue when attempting a large database import on my local development environment. The error I received indicated that the import was hitting the max execution time. I fired up XAMPP’s control panel, edited my php.ini file to bump the max execution time up to 600 seconds, restarted Apache and thought I’d be good to go.
Unfortunately, that isn’t the limit it was hitting…
While you indeed can edit your php.ini file to increase the max execution time, this only applies to your sites that you’re developing and not to phpMyAdmin. I’ll explain all of the settings I tweaked to help this import complete successfully.
Editing “xampp\phpmyadmin\config.inc.php”
You can either navigate straight to this file location in your operating system (OS) and edit with your editor of choice or you can open the XAMPP control panel and next to Apache click the Config button and click on phpMyAdmin (config.inc.php). From here you’ll need to add the following line:
$cfg[‘ExecTimeLimit’] = 3600;
The number here indicates how many seconds to allow a script to execute.
Editing “xampp\php\php.ini”
Next up, we’re going to edit a group of settings that pertain to longer execution time’s and/or increased resources available to PHP. I would recommend opening in a full-fledged IDE, Notepad++ or even a regular text editor like Windows’ Notepad or Linuxs’ Text Editor. Be sure to use find and replace actions to speed up searching for these flags.
max_execution_time = 3600
max_input_time = -1
memory_limit = 1024M
post_max_size = 1024M
upload_max_filesize = 1024M
Each of these settings are somewhat self-explanatory, but I’ll list them and their general purpose here:
- max_execution_time – Maximum execution time in seconds before the server stops executing a script.
- max_input_time – Maximum time in seconds a script is allowed to parse input data such as GET or POST. Setting to “-1” will fallback on the max_execution_time setting.
- memory_limit – Maximum allowable system memory allocated for a running script. Setting to “-1” means the script can consume all available system memory. “K” signifies “Kilobytes”, “M” signifies “Megabytes” and “G” signifies “Gigabytes”.
- post_max_size – Maximum allowed size in bytes of post data. File upload is also affected.
- upload_max_filesize – Maximum file size in bytes allowed when uploading a file to the server.
Editing “xampp\mysql\bin\my.ini”
Finally, we’re going to edit the MySQL max allowed packet size setting.
max_allowed_packet = 200M
The setting for max_allowed_packet will allow larger packets to be sent during an operation like an import. If you’re using large BLOB fields, this is a lifesaver as the default packet size is only 64MB. Once you’ve saved this last “.ini” file, you should stop Apache and MySQL and restart them from the XAMPP console.
Now you should be able to run larger imports on your XAMPP environment. Sound off in the comments below if you have any additional tweaks you can make to XAMPP configuration.