1

我尝试使用以下代码备份 MySQL 数据库:

$user="admin";
$pass="";
$dbname="mobiledb";
$backupFile = 'c:\\onstor.sql';
$command = "mysqldump  -u ".$user." -p".$pass." ".$dbname." > ".$backupFile;
system($command);

onstor.sql文件已创建,但其大小为 0 字节!

这有什么问题?

4

2 回答 2

3

尝试绝对引用 mysqldump:/usr/bin/mysqldump

或者在 Windows 中可能是这样的:C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump

于 2013-10-01T14:19:11.150 回答
0

Ensure you have the correct privileges to run mysqldump against your database.

As root run:

    GRANT SELECT, LOCK TABLES ON *.* TO admin@localhost

If still no luck, to help with identifying the root cause of the problem, run your mysqldump command from the command line (not via a script) just incase it is due to some file permission issues during standard output redirection.

于 2013-09-29T10:28:27.920 回答