|
-
Mar 30th, 2010, 01:23 AM
#1
Thread Starter
Hyperactive Member
MySQL Database Backup
I wish to restore the data of tables of my database into Excel(.xls) or any other format. Below is my code.
PHP Code:
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
$dbname = "test";
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$backupFile = "restore";
$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
system($command);
?>
There is no error. But I cannot see the output. Please tell me what is wrong with my code. Please rectify.
My environment is as below:
Windows XP
WampServer
Thanks a lot in advance.
-
Mar 30th, 2010, 08:15 AM
#2
Re: MySQL Database Backup
first, you're using the shorthand option p and aren't following its rules; -p must be followed by the password (no spaces!), otherwise the console will ask you for a password as if you haven't entered it. I would suggest using --host=, --user=, and --password= instead.
also, --opt is on by default (so you don't need to enable it) and --host defaults to localhost (assuming you're never changing the host name), just so you know. feel free to look at the documentation if you need more help using mysqldump.
then, make sure the value of $command is correct and will be able to run (echo out $command and run it in the command prompt).
-
Mar 30th, 2010, 07:35 PM
#3
Re: MySQL Database Backup
Try using passthru instead of system to see the output.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|