PHP: maximum execution time when importing .SQL data file
Solution 1
There's a configuration variable within the phpMyAdmin directory that you can find in libraries\config.default.php
called $cfg['ExecTimeLimit']
that you can set to whatever maximum execution time you need.
Solution 2
Well, to get rid of this you need to set phpMyadmin variable to either 0 that is unlimited or whichever value in seconds you find suitable for your needs. Or you could always use CLI(command line interface) to not even get such errors(For which you would like to take a look at this link.
Now about the error here, first on the safe side make sure you have set PHP parameters properly so that you can upload large files and can use maximum execution time from that end. If not, go ahead and set below three parameters from php.ini file,
- max_execution_time=3000000 (Set this as per your req)
- post_max_size=4096M
- upload_max_filesize=4096M
Once that's done get back to finding phpMyadmin config file named something like "config.default.php". On XAMPP you will find it under "C:\xampp\phpMyAdmin\libraries" folder. Open the file called config.default.php
and set :
$cfg['ExecTimeLimit'] = 0;
Once set, restart your MySQL and Apache and go import your database.
Enjoy... :)
Solution 3
Set Only 3 Parameters from php.ini
file of your server
A. max_execution_time = 3000000 (Set as per your requirment)
B. post_max_size = 4096M
C. upload_max_filesize = 4096M
Edit C:\xampp\phpMyAdmin\libraries\config.default.php
Page
$cfg['ExecTimeLimit'] = 0;
After all set, restart your server and import again your database.
Done
Solution 4
You're trying to import a huge dataset via a web interface.
By default PHP scripts run in the context of a web server have a maximum execution time limit because you don't want a single errant PHP script tying up the entire server and causing a denial of service.
For that reason your import is failing. PHPMyAdmin is a web application and is hitting the limit imposed by PHP.
You could try raising the limit but that limit exists for a good reason so that's not advisable. Running a script that is going to take a very long time to execute in a web server is a very bad idea.
PHPMyAdmin isn't really intended for heavy duty jobs like this, it's meant for day to day housekeeping tasks and troubleshooting.
Your best option is to use the proper tools for the job, such as the mysql commandline tools. Assuming your file is an SQL dump then you can try running the following from the commandline:
mysql -u(your user name here) -p(your password here) -h(your sql server name here) (db name here) < /path/to/your/sql/dump.sql
Or if you aren't comfortable with commandline tools then something like SQLYog (for Windows), Sequel Pro (for Mac), etc may be more suitable for running an import job
Solution 5
This worked for me.
If you got Maximum execution time 300 exceeded in DBIMysqli.class.php
file. Open the following file in text editor
C:\xampp\phpMyAdmin\libraries\config.default.php
then
search the following line of code:
$cfg[‘ExecTimeLimit’] = 300;
and change value 300
to 900
.
EssexPN
Updated on April 17, 2021Comments
-
EssexPN about 3 years
I am trying to import a large .sql data file using phpMyAdmin in XAMPP. However this is taking a lot of time and I keep getting:
Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\dbi\DBIMysqli.class.php on line 285
And the file is about 1.2 million lines long.
The file is about 30MB big, so it is not that big. I don't really understand why it is taking so long.
;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; ; Maximum execution time of each script, in seconds ; http://php.net/max-execution-time ; Note: This directive is hardcoded to 0 for the CLI SAPI max_execution_time=30000 ; Maximum amount of time each script may spend parsing request data. It's a good ; idea to limit this time on productions servers in order to eliminate unexpectedly ; long running scripts. ; Note: This directive is hardcoded to -1 for the CLI SAPI ; Default Value: -1 (Unlimited) ; Development Value: 60 (60 seconds) ; Production Value: 60 (60 seconds) ; http://php.net/max-input-time max_input_time=60 ; Maximum input variable nesting level ; http://php.net/max-input-nesting-level ;max_input_nesting_level = 64 ; How many GET/POST/COOKIE input variables may be accepted ; max_input_vars = 1000 ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit=200M
The is the config file for php.ini in xampp, for some reason i still get
Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\dbi\DBIMysqli.class.php on line 285.
-
EssexPN about 10 yearsfor some reason he gives me the same error. Fatal error: Maximum execution time of 300 seconds exceeded in C:\xampp\phpMyAdmin\libraries\dbi\DBIMysqli.class.php on line 285. Even though i have changed it to 100000
-
Neta Meta about 10 yearsthere there are 2 other possibility, your script doesnt have permission to change that, 2. the script DBIMysqli.class.php, overrides your max_execution_time.
-
EssexPN about 10 yearsin phpadmin, there is an option "Allow the interruption of an import in case the script detects it is close to the PHP timeout limit. (This might be a good way to import large files, however it can break transactions.)" if turned of might it help ?
-
Neta Meta about 10 yearsTry turning it off and see
-
Isaac Bennetch about 10 yearsSince the poster is using phpMyAdmin, I don't think opening the source code and finding the best place to put that line is an ideal solution.
-
Isaac Bennetch about 10 yearsSince the poster is using phpMyAdmin, I don't think opening the source code and finding the best place to put that line is an ideal solution.
-
aldemarcalazans almost 7 yearsThere is a comment inside the config.default.php, warning to not edit that file. This is because the configurations there can be overwritten by the configurations set in another file: config.inc.php. So, change the timeout as stated by Randell, but do that in the appropriate file.
-
Wes Henderson over 4 yearsThis worked perfectly. I just needed to update my test server. I wouldn't do this on my production server.