我一直得到这个PHP错误:
致命错误:Maximum execution time of 300 seconds exceeded
我已经尝试在php.ini (apache和cli)中设置我的max_execution_time
和max_input_time
设置为0
, -1
和4000
秒。
我仍然得到错误提示:
致命错误:Maximum execution time of 300 seconds exceeded
以及我的脚本运行超过300秒之前,我得到这个消息
我正在通过命令行运行脚本。
我也检查了我的phpinfo()
,看看我使用的是哪个php.ini
。
更有趣的是,我曾尝试将max_execution_time
和max_input_time
设置为5秒,我的脚本将运行超过5秒,然后我得到:
致命错误:Maximum execution time of 300 seconds exceeded
如果使用WAMP,请转到:
增加php.ini
中的max_execution_time
,然后转到
C:'wamp'apps'phpmyadmin3.4.10.1'libraries
(根据您的安装更改路径)
打开config.default.php
并将$cfg['ExecTimeLimit']
的值更改为0:
$cfg['ExecTimeLimit'] = 0;
这将解决PhpMyAdmin导入的问题。
Xampp用户
- 转到
xampp'phpMyAdmin'
开放config.inc.php - 查找
$cfg['ExecTimeLimit'] = 300;
- 设置一个更大的值或者将无限 更改为0
- 如果未找到添加
$cfg['ExecTimeLimit'] = 900;
(或0表示无限制) - 保存文件并重启服务器
重要:不建议设置为无限制。
在你的脚本开始你可以添加。
ini_set('MAX_EXECUTION_TIME', '-1');
我遇到过类似的情况,事实证明Codeigniter(我使用的PHP框架)实际上设置了自己的时间限制:
在system/core/Codeigniter.php中,2.1.3版本的第106行出现如下内容:
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
@set_time_limit(300);
}
由于没有其他方法可以避免更改核心文件,因此我删除了它,以便允许通过php.ini进行配置,并为CLI请求提供无限的最大执行时间。
但是,我建议在将来的CI版本升级中记录此更改。Xampp用户
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.
在脚本中尝试以下操作:
set_time_limit(1200);
进入xampp/phpmyadmin/libraries/config.default.php
并进行以下更改
from $cfg['ExecTimeLimit'] = ’300′;
to $cfg['ExecTimeLimit'] = ’0′;
正确答案:
去c:'wamp'apps'phpmyadmin3.4.10.1'libraries'config.default.php
查找和设置
$cfg['ExecTimeLimit'] = 0;
重启所有服务和完成。
为当地AppServ
转到C:'AppServ'www'phpMyAdmin'libraries'config.default.php
查找$cfg['ExecTimeLimit']
并设置value为0
所以它看起来像
$cfg['ExecTimeLimit'] = 0;
如果xampp在本地服务器转到 C: ' xampp ' phpMyAdmin '图书馆' config.default.php
//find $cfg['ExecTimeLimit']= 300;
//increase this value
$cfg['ExecTimeLimit'] = 3000;
所以,花了几个小时后,这对我来说是有效的(2023)
-
添加$cfg['ExecTimeLimit'] = 6000;到xampp/phpMyAdmin/config.inc.php
-
我也改变$cfg['ExecTimeLimit'] = 6000;在xampp/phpMyAdmin/libraries/configdefault.php
PHP的CLI默认执行时间是无限的。
设置允许脚本运行的最长时间(以秒为单位)在被解析器终止之前。这有助于预防从绑定服务器编写脚本。默认值为30。当从命令行运行PHP时,默认设置为0。
http://gr.php.net/manual/en/info.configuration.php ini.max-execution-time
检查你是否在安全模式下运行PHP,因为在安全模式下它会忽略所有的时间执行设置。
在Xampp上,在php.ini中必须检查mysql。connect_timeout。例如,将其更改为:
mysql.connect_timeout = 3600
该时间将始终以秒为单位计算(因此在我的示例中为1小时)
MAMP USERS编辑php.ini解决了这个问题-有一行:
max_execution_time = 30;每个脚本的最大执行时间,以秒为单位
设置一个更高的值就可以了。
文件位于php/php5.6.25/conf/php.ini(显然,您需要为您正在使用的php版本润色文件-您可以从MAMP首选项中找到这一点。)
如果您正在使用xampp并使用phpMyadmin导入大型sql文件,并且您已经增加了max_执行时间,最大文件上传限制和所需的所有内容,如果上述答案都不适合您来这里
转到xampp文件夹,这里是我需要修改的文件的相对路径: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;
WAMP USERS:
1)进入C:'wamp'apps'phpmyadmin
2)打开config.inc 3)添加$cfg['ExecTimeLimit'] = ' 3600 ';到文件4)保存文件并重启服务器
这个文件会覆盖php.ini并且会为你工作!
在我的情况下,当我在Phpmyadmin中遇到这个错误时,我尝试了MySQL-Front并成功导入了我的数据库。
注意:你仍然可以在Phpmyadmin中使用这个问题下提供的解决方案来解决你的问题。
如果上面的答案不起作用,试着检查你的代码,根据我的经验,有一个无限循环也会导致这个问题。检查else if语句。
在Codeignitor 3.0版本。在system/core/Codeigniter.php中不包含时间限制以及插入
ini_set('MAX_EXECUTION_TIME', -1);
不能工作,因为codeignitor会用自己的函数set_time_limit()覆盖它。要么从codeignitor中删除这个函数要么直接插入
set_time_limit('1000');
如果您想将其更改为1000秒,则在PHP文件的开头设置。如果您想要运行它,请将时间设置为0(零)。
在我的配置中,我有多个phpmyadmins,配置文件中的值在wamp/alias/phpmyadmin.conf
中被覆盖。我在这里设置了两行:
1。 php_admin_value max_execution_time 3600
2。 php_admin_value max_input_time 3600
…终于成功了!
For OpenServer
modules'system'html'openserver'phpmyadmin'libraries'config.default.php
改变$cfg[‘ExecTimeLimit’] = 600
可以设置时间限制:
ini_set('max_execution_time', 1000000000000000);