如何用PHP通过电子邮件自动备份MySQL数据库表
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何用PHP通过电子邮件自动备份MySQL数据库表相关的知识,希望对你有一定的参考价值。
<? // Create the mysql backup file // edit this section $dbhost = "yourhost"; // usually localhost $dbuser = "yourusername"; $dbpass = "yourpassword"; $dbname = "yourdb"; $sendsubject = "Daily Mysql Backup"; $bodyofemail = "Here is the daily backup."; // don't need to edit below this section // Mail the file include('Mail/mime.php'); $message = new Mail_mime(); $text = "$bodyofemail"; $message->setTXTBody($text); $message->AddAttachment($backupfile); $body = $message->get(); $headers = $message->headers($extraheaders); $mail->send("$sendto", $headers, $body); // Delete the file from your server ?>
以上是关于如何用PHP通过电子邮件自动备份MySQL数据库表的主要内容,如果未能解决你的问题,请参考以下文章
如何用Percona XtraBackup进行MySQL从库的单表备份和恢复