致命错误:尝试备份数据库时,允许的内存大小为33554432字节已用尽(尝试分配91字节)错误 [英] Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 91 bytes) error while trying to backup database
问题描述
我遇到致命错误:尝试使用Codeigniter dbutil backup()函数在联机休息服务器上备份数据库时,允许的内存大小为33554432字节已用尽(尝试分配91字节)错误。
I got Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 91 bytes) error while trying to backup database on online rest server using Codeigniter dbutil backup() function.
这是我的代码:
$this->load->dbutil();
$backup =& $this->dbutil->backup();
$this->load->helper('file');
write_file('./uploads/db/mybackup.gz', $backup);
我找不到我做错的地方。
I can't find out where I am doing wrong.
推荐答案
您需要使用以下命令来增加脚本内存:
You need to increase your script memory by using this:
ini_set('memory_limit', '-1');
您需要在文件顶部使用此行。
You need to use this line at the top of file.
通过增加 memory_limit ,您的脚本将无限使用服务器的内存。
By increasing memory_limit your script will take unlimited memory usage of server.
如果您可以访问 php .ini 文件,则可以从 php.ini 文件中增加限制,否则需要添加此行。
If you have access on php.ini file than you can increase limit from php.ini file otherwise you need to add this line.
旁注:
如果您认为在其他区域会受到无限内存的影响,则可以将自定义值设置为:
If you think unlimited memory will be effected on other areas than you can set custom value as:
ini_set('memory_limit', '512M'); //increase size as you need
这篇关于致命错误:尝试备份数据库时,允许的内存大小为33554432字节已用尽(尝试分配91字节)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!