...

View Full Version : mysqldump



phantom007
07-12-2007, 03:06 PM
Hi

Does anyone know what is the simplest way to backup a database using the mysqldump function in php?


I have googled a lot and the codes i have found are very hard to understand and most of them does not work.



Thanx in advance for your help.

devinemke
07-12-2007, 04:37 PM
exec('/path/to/mysqldump --host=hostname --user=username --password=password dbname >output.sql');

mcjwb
07-12-2007, 04:41 PM
There is no mysqldump function in php. Do you mean the mysqldump executable supplied with MySQL?
If so you can run mysqldump from php using:


$host="localhost";
$username="root";
$password="myPassword";
$database="myDbName";
$path="C:\\";
$filename="myDbBackup.sql";
$command ="mysqldump --host=$host --user=$username --password=$password $database > $path/$filename";
exec($command);
Subsitute your values as applicable.

phantom007
07-12-2007, 07:10 PM
HI

Thanx for your reply. Now can u tell me how would I restore my data to the database?

devinemke
07-12-2007, 07:19 PM
LOAD DATA INFILE (http://dev.mysql.com/doc/refman/5.0/en/load-data.html)

StupidRalph
07-12-2007, 07:20 PM
$command = "mysql -u USER -p DBNAME < myDbBackup.sql";
exec($command);

Should be something like this if I remember correctly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum