Backup mysql data using PHP in Windows

How to backup mysql data using PHP in Windows XP, 2000, NT

More PHP Resources


I’ll make this really short and simple.

First, create a folder (call it anything you want to) under htdocs [If you are using apache].Lets call it ‘backup’.

Now browse to the `bin` folder of mysql. On my computer it is `c:\mysql\bin`. From here copy the `mysqldump.exe` file and move it to the folder you just created (`backup`).

Here is the php script that you need to use to make a backup copy of mysql database:

$list = shell_exec ("mysqldump database_name > C:\\file_name.sql");
echo $list."Success";

Lets look at the code….

We have used shell_exec() function to execute a system command.

Replace `database_name` with the name of your database that you want to backup and you are all set. If you have any questions feel free to contact me

Note: Make sure that the PHP script and the mysqldump file reside in the same folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top