简体   繁体   English

phpMyAdmin无法导出数据库

[英]phpMyAdmin can't export database

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: 我有一台VPS计算机,我安装了phpMyAdmin并将数据库插入其中。但是现在当我要进行备份并导出数据库时,它说:

错误代码500,内部服务器错误

Here is the error.log: http://pastebin.com/44N4YcAk 这是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 [2013年6月18日21:40:16周二] [错误] [客户端] PHP致命错误:在/usr/share/phpmyadmin/libraries/tcpdf/tcpdf.php中,已用尽16777216字节的内存容量(尝试分配491520字节)

you should not be using phpmyadmin for this, you should be using mysqldump. 您不应该为此使用phpmyadmin,而应该使用mysqldump。 from the command line its 从命令行

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

from a php script 从PHP脚本

$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 这很容易与cronjob自动化

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. 您的VPS内存不足,或者您的PHP设置不允许分配超过16MB的内存。

Increase the memory in php.ini or just use mysqldump 增加php.ini中的内存或仅使用mysqldump

php.ini change php.ini更改

memory_limit = 64M  

I strongly recomend using mysqldump though here is an extract from my backup script 我强烈建议使用mysqldump,尽管这是我的备份脚本的摘录

#!/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 将备份保存在受密码7zpass保护的7zip文件中

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 如何增加phpmyadmin的内存大小

do this command: 执行以下命令:

nano /usr/share/phpmyadmin/export.php

press ctrl+w and find: 按ctrl + w并找到:

// 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: 此命令在文件中使用了两次,此命令在您看到嵌套的if之后,因此在嵌套的if中进行了更改:

break 2;

to

break;

in both cases after this your export function will work well 在这两种情况下,导出功能都可以正常工作

Tip: 小费:

Change the mysql engine to InnoDB instead of MyISAM, the main purpose is claiming storage after cleaning tables or dropping them. 将mysql引擎更改为InnoDB而不是MyISAM,主要目的是在清理表或删除表后声明存储空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM