简体   繁体   English

带有 php 的空 mysqldump 文件

[英]empty mysqldump file with php

I am trying to backup a database using the PHP system command and mysqldump.exe.我正在尝试使用 PHP 系统命令和 mysqldump.exe 备份数据库。 I have specified the absolute path to mysqldump.exe, followed by various options.我已经指定了 mysqldump.exe 的绝对路径,然后是各种选项。

This is how I am currently making the call -这就是我目前拨打电话的方式-

$path = "C:\Documents and Settings\User\Desktop\ABCD\mysqldump.exe";
$command = $path." <dump options>" > <backup filename> ";
system($command);

This is generating a sql file with absolutely no contents.这将生成一个绝对没有内容的 sql 文件。 I figured the problem is because of the spaces in the path name, because我认为问题是因为路径名中的空格,因为

$path = "C:\ABCD\mysqldump.exe";
$command = $path." <dump options>" > <backup filename> ";
system($command);

works absolutely fine.工作得很好。

I am unable to figure out how to make things work when the path contains spaces.当路径包含空格时,我无法弄清楚如何使事情正常进行。 I checked other threads which talked about escapeshellarg, etc but using that on the path doesn't work either.我检查了其他讨论 escapeshellarg 等的线程,但在路径上使用它也不起作用。

Please help.请帮忙。

Are you really doing this?你真的在这样做吗?

$system($command);

Should instead be:应该是:

// No $ on system()
system($command);

Also, try double backslashes for Windows paths:此外,对 Windows 路径尝试双反斜杠:

$path = "\"C:\\Documents and Settings\\User\\Desktop\\ABCD\\mysqldump.exe\"";

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

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