我从数据库PHP导出有什么问题?

时间:2014-01-19 23:23:40

标签: php mysql export

尝试使用此PHP从数据库导出但不起作用。

代码抛出以下错误消息: '在dbname导出到〜/ chooseFilenameForBackup.sql期间出现了警告。'

帮助表示感谢。

<?php
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName ='dbname';
$mysqlUserName ='root';
$mysqlPassword ='password';
$mysqlHostName ='localhost';
$mysqlExportPath ='chooseFilenameForBackup.sql';

//DO NOT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' > ~/' .$mysqlExportPath;
exec($command,$output=array(),$worked);
switch($worked){
case 0:
echo 'Database <b>' .$mysqlDatabaseName .'</b> successfully exported to <b>~/' .$mysqlExportPath .'</b>';
break;
case 1:
echo 'There was a warning during the export of <b>' .$mysqlDatabaseName .'</b> to <b>~/' .$mysqlExportPath .'</b>';
break;
case 2:
echo 'There was an error during export. Please check your values:<br/><br/><table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td></tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' .$mysqlHostName .'</b></td></tr></table>';
break;
}
?>

1 个答案:

答案 0 :(得分:0)

您使用的是本地安装的php,在上传到我的服务器然后导出成功之前我遇到了同样的错误