Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

MySqldump creates empty file?

Trying to backup database



9:59 pm on Aug 21, 2006 (gmt 0)

10+ Year Member

I am Trying to create a one click backup database script so non-geek office staff can do this, but so far I can only output empty files

$db_user = "root";
$db_password = "";
$db_database = "or";
$db_server = "localhost";
$backup_path = "C:\\xampp\\htdocs\\openreal\\admin\\backup\\";
$path_to_mysqldump = "C:\\xampp\\mysql\\bin\\";
$filename = "backup".date("YmdHis").".sql";

shell_exec ("mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password");

I have tried various forms of this syntax with no content output?


5:21 pm on Aug 22, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

have you tried you dump command via command line to see if it works? Start with that

echo your full line to try it

$dumpcmd = 'mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password';

echo $dumpcmd;

then paste it via the command line and see what it does


4:32 am on Aug 23, 2006 (gmt 0)

10+ Year Member

Good clue -
did some testing on the cmd window and got it all working : ie, this command writes a db dump to the file in temp -

C:\xampp\mysql\bin\mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > C:\temp\.mychat.sql ; system

but in php it writes the file ok but it is empty (0 bytes)

This is my php version of the same command -

$dump_cmd=("$path_to_mysqldump.mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > $backup_path.$filename ");


10:47 am on Aug 23, 2006 (gmt 0)

10+ Year Member

OK - problem solved -

Seems the "$path_to_mysqldump" has to be in there too.

This code works fine now on my local machine :

$fish= "$path_to_mysqldump\\mysqldump.exe --u $db_user --ignore-table=$db.$config $db > $filename ";


You would need --p=$passwd after User (if it was set)


Featured Threads

Hot Threads This Week

Hot Threads This Month