phpMyAdmin can't export database

2019-06-08 22:30发布

I have a VPS machine and I installed phpMyAdmin and inserted the database in. But now when I want to make a backup and export the database, it says:

Error code 500, Internal Server Error

Here is the error.log: http://pastebin.com/44N4YcAk

[Tue Jun 18 21:40:16 2013] [error] [client] PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 491520 bytes) in /usr/share/phpmyadmin/libraries/tcpdf/tcpdf.php

5条回答
甜甜的少女心
2楼-- · 2019-06-08 22:54

you should not be using phpmyadmin for this, you should be using mysqldump. from the command line its

mysqldump -uMYSQL-USER -h server -pMYSQL-USER database_name > /path-to-export

from a php script

$command = "mysqldump -uMYSQL-USER -h server -pMYSQL-USER database_name > /path-to-export/file.sql";
exec($command, $output, $return_var);

this is easy to automate with a cronjob

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-06-08 23:08

It says at the bottom

 PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried to allocate 491520 bytes) in /usr/share/phpmyadmin/libraries/tcpdf/tcpdf.php on line 22694, 

Either your VPS is out of memory or your PHP settings are not allowing more than 16MB of memory to be allocated.

Increase the memory in php.ini or just use mysqldump

php.ini change

memory_limit = 64M  

I strongly recomend using mysqldump though here is an extract from my backup script

#!/bin/bash
time=`date +%Y-%m-%d_%H-%M-%S`
mysqldump -u mysqluser -pmysqlpassword --all-databases | 7za a -si database/backup-${time}.sql.7z -p7zpass

That saves the backup in a 7zip file protected by the password 7zpass

查看更多
Evening l夕情丶
4楼-- · 2019-06-08 23:14

Go through this post, it shows how to increase the memory; or just use command line to import:

How to increase memory size for phpmyadmin

查看更多
一夜七次
5楼-- · 2019-06-08 23:16

Tip:

Change the mysql engine to InnoDB instead of MyISAM, the main purpose is claiming storage after cleaning tables or dropping them.

查看更多
孤傲高冷的网名
6楼-- · 2019-06-08 23:20

do this command:

nano /usr/share/phpmyadmin/export.php

press ctrl+w and find:

// now export the triggers (needs to be done after the data because

this command used twice in the file after this command you see nested if, so in the nested if change:

break 2;

to

break;

in both cases after this your export function will work well

查看更多
登录 后发表回答