我想使用PHP导入和导出MySQL数据库
我在localhost上并使用easyphp
我试过这段代码
<?php
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName ='naql';
$mysqlUserName ='root';
$mysqlPassword ='';
$mysqlExportPath ='chooseFilenameForBackup.sql';
//DO NOT EDIT BELOW THIS LINE
$mysqlHostName ='localhost';
//Export the database and output the status to the page
$command='mysqldump -u' .$mysqlUserName .' -S /kunden/tmp/mysql5.sock -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;
}
?>
但它根本不起作用。我收到此错误
Strict Standards: Only variables should be passed by reference in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\projects\1na9liyat\admin lab RTL template\databasephp.php on line 13
There was a warning during the export of naql to ~/chooseFilenameForBackup.sql
答案 0 :(得分:0)
欢迎来到SO。
这个问题更像是一个php问题而不是mysql问题。你必须通过php运行dump-command吗?您可能希望直接从命令行运行mysqldump。
如果您有MyISAM表,则只需复制该表的三个文件(.frm,.MYD,.MYI)即可创建该表的备份。