26.06.2014 Views

Using PHP To Backup MySQL Database

Using PHP To Backup MySQL Database

Using PHP To Backup MySQL Database

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> <strong>PHP</strong> <strong>To</strong> <strong>Backup</strong> <strong>MySQL</strong> <strong>Database</strong><br />

Ads by Goooooogle<br />

Free <strong>MySQL</strong> Dev <strong>To</strong>ol<br />

Create, execute & modify queries Download <strong>To</strong>ad for<br />

<strong>MySQL</strong> freeware<br />

www.quest.com<br />

<strong>PHP</strong> <strong>MySQL</strong> generator<br />

Generate <strong>PHP</strong> code for any local or remote <strong>MySQL</strong><br />

database.<br />

www.xlinesoft.com/phprunner<br />

<strong>MySQL</strong> <strong>Backup</strong> GUI<br />

Schedule <strong>Backup</strong>, Import/Export <strong>Database</strong> Admin,<br />

Reporting for <strong>MySQL</strong><br />

www.navicat.com<br />

<strong>MySQL</strong> Automation<br />

Schedule backup and restore of your <strong>MySQL</strong> server with<br />

this software.<br />

www.mysqlmaestro.com<br />

There are at least three ways to backup your <strong>MySQL</strong> <strong>Database</strong> :<br />

1. Execute a database backup query from <strong>PHP</strong> file.<br />

2. Run mysqldump using system() function.<br />

3. Use phpMyAdmin to do the backup.<br />

Execute a database backup query from <strong>PHP</strong> file<br />

Below is an example of using SELECT INTO OUTFILE query for creating table backup :<br />

<br />

<strong>To</strong> restore the backup you just need to run LOAD DATA INFILE query like this :<br />


$tableName";<br />

$result = mysql_query($query);<br />

include 'closedb.php';<br />

?><br />

It's a good idea to name the backup file as tablename.sql so you'll know from which table the backup file is<br />

Run mysqldump using system() function<br />

The system() function is used to execute an external program. Because <strong>MySQL</strong> already have built in tool for<br />

creating <strong>MySQL</strong> database backup (mysqldump) let's use it from our <strong>PHP</strong> script<br />

<br />

Use phpMyAdmin to do the backup<br />

This option as you may guessed doesn't involve any programming on your part. However I think i mention it<br />

anyway so you know more options to backup your database.<br />

<strong>To</strong> backup your <strong>MySQL</strong> database using phpMyAdmin click on the "export" link on phpMyAdmin main page.<br />

Choose the database you wish to backup, check the appropriate SQL options and enter the name for the<br />

backup file.<br />

<strong>MySQL</strong> Automation<br />

Schedule backup and restore of your<br />

<strong>MySQL</strong> server with this software.<br />

Generate <strong>PHP</strong> From <strong>MySQL</strong> .<br />

Bring Your <strong>Database</strong> Online. Create <strong>PHP</strong><br />

Scripts From <strong>MySQL</strong> <strong>Database</strong> !<br />

Ads by Goooooogle<br />

<strong>MySQL</strong> Update and Delete<br />

<strong>PHP</strong> <strong>MySQL</strong> Tutorial : <strong>Backup</strong><br />

<strong>MySQL</strong> <strong>Database</strong><br />

Form Validation With <strong>PHP</strong><br />

This tutorial is far from perfect so if you have any critiques, questions, comments or problems about this<br />

tutorial please tell me. Click here to send your feedback. And if you like this tutorial please link to this site. It will<br />

really help a lot :-)


"The World's ONLY True-Blue,<br />

Real Link Exchanger that WORKS!" .<br />

Copyright © 2004 - 2005 www.php-mysql-tutorial.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!