109

I keep getting this PHP error:

Fatal error: Maximum execution time of 300 seconds exceeded

I have tried setting my max_execution_time and my max_input_time settings in php.ini (both apache and cli) to 0, -1 and 4000 seconds each.

And i still get the error saying:

Fatal error: Maximum execution time of 300 seconds exceeded

As well my script runs over 300 seconds before i get this message

I am running the script through command line.

I also checked my phpinfo() so see which php.ini I am using.

Even more interesting I have tried setting max_execution_time and max_input_time settings to 5 second and my script will run way beyond 5 seconds before I get the:

Fatal error: Maximum execution time of 300 seconds exceeded

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
dez
  • 2,195
  • 6
  • 25
  • 29
  • What kind of server setup are you on? – Pekka Oct 06 '11 at 21:20
  • 1
    This is so strange i have same issue on apache 2.4.18 and php 7... Using PHPMyAdmin to import sql.. phpinfo(); reports different time.. Will try the ini setting I guess :( – Michael Fever Feb 25 '16 at 21:29
  • the same issue, I try to set set_time_limit(3603); ini_set('max_execution_time', 3604); but both have no effect, max execution time still is 360. – Infor Mat Feb 05 '20 at 14:26

22 Answers22

106

If you are using WAMP Go to :

Increase the max_execution_time in php.ini then go to

C:\wamp\apps\phpmyadmin3.4.10.1\libraries (change path according to your installation)

open config.default.php and change value for $cfg['ExecTimeLimit'] to 0:

$cfg['ExecTimeLimit'] = 0;

This will resolve the issue for PhpMyAdmin imports.

yarl
  • 3,107
  • 1
  • 22
  • 28
Vipin Dubey
  • 1,393
  • 3
  • 10
  • 13
  • @Vipin, you solution helped me, especially that config.default.php ;-) – Rishi Kulshreshtha Feb 18 '14 at 05:16
  • thank you, after hrs and hrs of frustration trying to upgrade a 500 MB DB to a newer version of moodle......I have success. Specifically moodle 2.2 - 2.6. – jamesTheProgrammer Apr 04 '14 at 20:03
  • THIS is the answer I've been looking for! – jdstankosky Jun 17 '14 at 11:28
  • 2
    Thanks for this answer! Helped out my problem after realizing that setting the max execution time in php.ini wasnt enought! – Rimble Oct 04 '14 at 14:48
  • 1
    `config.default.php` is very explicit about not editing it, telling us to edit `config.inc.php` instead. I tried to find it and could not, so I made my own and added ``. This did nothing. I decided to try and do it in `config.default.php` and it worked!! How are we supposed to make the `config.inc.php` work?!? – BillyNair Feb 15 '15 at 09:20
  • Hi, in WAMP 3.x what I had to do was finding the phpmyadmin.conf file and edit the "max_execution_time" variable there. – Emanuele Ciriachi Nov 15 '17 at 21:41
  • 2
    @BillyNair config.inc.php is in the phpmyadmin root directory – Tschallacka Aug 22 '19 at 07:12
89

Xampp Users

  1. Go to xampp\phpMyAdmin\
  2. Open config.inc.php
  3. Search for $cfg['ExecTimeLimit'] = 300;
  4. Set a larger value or change to 0 for unlimited
  5. If not found add $cfg['ExecTimeLimit'] = 900; (or 0 for unlimited)
  6. Save the file and restart the server

Important: setting the execution time limit to unlimited is not recommended.

Technotronic
  • 8,424
  • 4
  • 40
  • 53
  • 10
    This is literally the only thing that worked for me. So thanks for posting. In my setup, $cfg['ExecTimeLimit'] = 300; didn't exist in config.inc.php so I added it there rather than changing the value in config.default.php--there is a rather large message stating not to touch the code in that file ;) – Ian Mar 28 '14 at 15:07
  • 6
    thanks for highlighting **restart the server**. most important forgettable point. – Pradeep Kumar Jul 01 '15 at 07:14
  • 4
    There is a note in the config.default.php file that says "No!! Do Not Edit". I added $cfg['ExecTimeLimit'] = 0; to my config.inc.php file since it didn't exist and it seemed to work. – brandozz Mar 08 '16 at 17:04
  • 1
    this post save my day and helped me for second time !!! how can i plus one after 3 month??? – saber tabatabaee yazdi Jan 14 '20 at 17:27
76

At the beginning of your script you can add.

ini_set('MAX_EXECUTION_TIME', '-1');
reformed
  • 4,505
  • 11
  • 62
  • 88
Tules
  • 4,905
  • 2
  • 27
  • 29
25

I encountered a similar situation, and it turns out that Codeigniter (the PHP framework I was using) actually sets its own time limit:

In system/core/Codeigniter.php, line 106 in version 2.1.3 the following appears:

if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
    @set_time_limit(300);
}

As there was no other way to avoid changing the core file, I removed it so as to allow configuration through php.ini, as well as give the infinite maximum execution time for a CLI request.

I recommend recording this change somewhere in the case of future CI version upgrades however.

xiankai
  • 2,773
  • 3
  • 25
  • 31
  • 8
    OH. MY. GOODNESS. I cannot believe this. Why is the bloody world would they limit execution time on top of all the other limits of execution time that already exist? I have wasted hours on this. Thank you for posting. – fool4jesus Nov 04 '13 at 22:42
  • 1
    That's unbelievable. Commented out the line and works! Why would CI overwrite the default PHP default, and not provide documentation on it?! – Phil Cross Apr 14 '14 at 12:24
  • If you're reading this and you're using ExpressionEngine (which is built on CodeIgniter)... Well - guess what - EE overrides CI's override! You'll need to edit both /system/codeigniter/system/core/Codeigniter.php line 106, AND /system/expressionengine/libraries/Core.php, line 64. That was a fun three hours of my life discovering that... – Jack Mar 04 '15 at 16:27
  • @PhilCross if you know the function that needs to execute more time, you can use [Jess' suggestion](http://stackoverflow.com/questions/7680572/fatal-error-maximum-execution-time-of-300-seconds-exceeded#comment10645588_7680610) and place `set_time_limit(0);` inside that function. You don't need to change the core: this instruction will reset the time limit, so you don't need to worry about other lines in the core or in other packages while running that specific function. – Armfoot Oct 09 '15 at 16:44
12

For Xampp Users

1. Go to C:\xampp\phpMyAdmin\libraries
2. Open config.default.php
3. Search for $cfg['ExecTimeLimit'] = 300;
4. Change to the Value 300 to 0 or set a larger value
5. Save the file and restart the server
6. OR Set the ini_set('MAX_EXECUTION_TIME', '-1'); at the beginning of your script you can add.
Rafiqul Islam
  • 931
  • 11
  • 14
10

Try something like the following in your script:

set_time_limit(1200);
Darth Egregious
  • 18,184
  • 3
  • 32
  • 54
9

go to the xampp/phpmyadmin/libraries/config.default.php

and make the following changes

from  $cfg['ExecTimeLimit'] = ’300′;
to  $cfg['ExecTimeLimit'] = ’0′;
maazza
  • 7,016
  • 15
  • 63
  • 96
Gaurav Arora
  • 121
  • 1
  • 3
7

This is the the right answer:

go to

c:\wamp\apps\phpmyadmin3.4.10.1\libraries\config.default.php

find and set

$cfg['ExecTimeLimit'] = 0;

restart all services and done.

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
llioor
  • 5,804
  • 4
  • 36
  • 44
4

For Local AppServ

Go to C:\AppServ\www\phpMyAdmin\libraries\config.default.php

Find $cfg['ExecTimeLimit'] and set value to 0.

So it'll look like

$cfg['ExecTimeLimit'] = 0;
davidkonrad
  • 83,997
  • 17
  • 205
  • 265
3

If xampp in localserver Goto C:\xampp\phpMyAdmin\libraries\config.default.php

//find $cfg['ExecTimeLimit']= 300;
//increase this value 
$cfg['ExecTimeLimit'] = 3000;
MOAZZAM RASOOL
  • 159
  • 1
  • 3
3

So, after spending hours, this works for me (2023)

  1. adding $cfg['ExecTimeLimit'] = 6000; into xampp/phpMyAdmin/config.inc.php

  2. also I change $cfg['ExecTimeLimit'] = 6000; in xampp/phpMyAdmin/libraries/configdefault.php

Imran_Developer
  • 343
  • 5
  • 13
1

On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:

mysql.connect_timeout = 3600

That time will be always counted in seconds (so 1 hour in my example)

andymnc
  • 103
  • 7
1

MAMP USERS editing php.ini solves this - there is a line:

max_execution_time = 30 ; Maximum execution time of each script, in seconds

setting this to a higher value worked.

the file is in php/php5.6.25/conf/php.ini (obviousl you need to wet the file for the php version you are using - you can find this out from the MAMP preferences.

Jeremy Young
  • 184
  • 1
  • 7
1

If you are on xampp and using phpMyadmin to import large sql files and you have increased max_execution time, max file upload limit and everything needed And If none of the above answers work for you come here

Go to your xampp folder, in my case here is the relative path to the file that I need to modify: C:\xampp\phpMyAdmin\libraries\config.default.php

/** * maximum execution time in seconds (0 for no limit) * * @global integer $cfg['ExecTimeLimit'] * by defautlt 300 is the value * change it to 0 for unlimited * time is seconds * Line 709 for me */ $cfg['ExecTimeLimit'] = 0;

Noor Ahmed
  • 178
  • 12
1

PHP's CLI's default execution time is infinite.

This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.

http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time

Check if you're running PHP in safe mode, because it ignores all time exec settings when on that.

Mob
  • 10,958
  • 6
  • 41
  • 58
0

WAMP USERS:

1) Go to C:\wamp\apps\phpmyadmin

2) Open config.inc

3) Add $cfg['ExecTimeLimit'] = ’3600′; to the file.

4) Save the file and restart the server.

This file overwrites the php.ini and will work for you!

Asi
  • 395
  • 4
  • 13
0

In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.

Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.

Jamshid Hashimi
  • 7,639
  • 2
  • 28
  • 27
0

If above answers will not work, try to check your code,,In my experience,having an infinite loop will also cause that problem.Check your else if statement.

0

In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting

ini_set('MAX_EXECUTION_TIME', -1);  

will not work since codeignitor will override that with its own function set_time_limit() . So either you have to delete that function from codeignitor or simply you can insert

set_time_limit('1000');

in the beginning of the php file if you wanna change that to 1000 seconds. Set the time to 0 (zero) if you want to run it as long as it want.

Wenuka
  • 887
  • 2
  • 9
  • 25
0

On wamp in my configuration where I have multiple phpmyadmins, the values in config files were overwritten in wamp/alias/phpmyadmin.conf. I set up two lines there:

1. php_admin_value max_execution_time 3600

2. php_admin_value max_input_time 3600

... it finally worked!

J. M. Arnold
  • 6,261
  • 3
  • 20
  • 38
0

For OpenServer

modules\system\html\openserver\phpmyadmin\libraries\config.default.php

change

$cfg[‘ExecTimeLimit’] = 600
YurgenTM
  • 83
  • 1
  • 6
-2

You can set time limit:

ini_set('max_execution_time', 1000000000000000);
binhhoang18
  • 589
  • 6
  • 9