我尝试使用以下代码备份 MySQL 数据库:
$user="admin";
$pass="";
$dbname="mobiledb";
$backupFile = 'c:\\onstor.sql';
$command = "mysqldump -u ".$user." -p".$pass." ".$dbname." > ".$backupFile;
system($command);
该onstor.sql
文件已创建,但其大小为 0 字节!
这有什么问题?
尝试绝对引用 mysqldump:/usr/bin/mysqldump
或者在 Windows 中可能是这样的:C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump
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.