本文介绍了将mysql数据库导出到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要备份mydatabase
i need to backup mydatabase
public function back() {
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = '';
$dbname = 'tawrny_dr';
$backup_file = $dbname . date("Y-m-d-H-i-s") . '.sql';
//DO NOT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command = 'mysqldump --opt -h' . $dbhost . ' -u' . $dbuser . ' -p' . $dbpass . ' ' . $dbname . ' > ~/' . $backup_file;
exec($command, $output = array(), $worked);
switch ($worked) {
case 0:
echo 'Database <b>' . $dbname . '</b> successfully exported to <b>~/' . $backup_file . '</b>';
break;
case 1:
echo 'There was a warning during the export of <b>' . $dbname . '</b> to <b>~/' . $backup_file . '</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>' . $dbname . '</b></td></tr><tr><td>MySQL User Name:</td><td><b>' . $dbname . '</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' . $dbhost . '</b></td></tr></table>';
break;
}
die();
}
但没有任何反应
当我把
if(!exec('cd。')){die('ERROR:Exec not available !!!'' );}
输出
but nothing happens
when i put
if(!exec('cd .')){ die('ERROR: Exec is not available!!!"'); }
it output
ERROR: Exec is not available!!!"
推荐答案
这篇关于将mysql数据库导出到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!