I want to create a backup from a database, but I get only a blank file.
include('config.php');
$command = "mysqldump --opt -h ".$_host." -u ".$_user." -p ".$_pass." ".$_db." > test.sql";
exec($command);
echo "<br />".$command;
test.sql is created where the .php file is located.
Edit:
Note! I'm using XAMPP WINDOWS !
Solution:
Because I'm using a Windows Web Server (XAMPP), I needed to specify the path:
$command = 'd:\xampp\mysql\bin\mysqldump --opt -u '.$_user.' -p'.$_pass.' '.$_db.' > test.sql';
- I removed the space between the -p and the pass. It looks like:
-pMYPASSWORD
- Replaced
"
with'
I think if you are using a Linux based web server, you don't have to specify the path for mysqldump.
Cheers! :-)