homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

MySqldump creates empty file?
Trying to backup database

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

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)

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)

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)

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)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved