Reputation:
i tried the solution of Ngu Soon Hui and it works. how about the mysqldump. i tried using the same solution.
$cmd = $mySQLDir1.' -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';
exec('"'.$cmd.'"',$out ,$retval);
where
$mysqlDire1 = $mySQLDir1='"C:\\Web\\WebServer\\mysql\\bin\\mysqldump.exe"';
$file2 = '"C:\\database_backup\\purchase_sales.sql"';
but this makes a file with this content.
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
any help will be appreciated.
Upvotes: 0
Views: 504
Reputation: 488744
You're not specifying which database to back up. Try adding it one, as the prompt suggests:
$cmd = $mySQLDir1.' mydatabasename -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';
Tested and works.
Upvotes: 2
Reputation: 90961
First thing after you declare $cmd
echo it, take that output and type it into the run prompt or a command prompt and see what the output is.
Upvotes: 0