简体   繁体   中英

Importing and Exporting MySQL Databases Using PHP on easyphp

i want to Importing and Exporting MySQL Databases Using PHP

I am on localhost and use easyphp

i have try this code

<?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;
}
?>

but it's not working at all. I get this error

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

Welcome to SO.

This Problem is more a php question than a mysql-Problem. Do you have to run the dump-command by php? You might want to run mysqldump directly from command-line.

If you have MyISAM Tables you can just copy the three files of that table (.frm, .MYD, .MYI) to create a backup of this table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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