I need to dump the entire database to a text file, but mysqldump is not outputting anything. Here is the command i'm executing via php script:
<?php
$_user="root";
$_pass="";
$_db="somedb";
$_host = "localhost";
$filename = "somedb.zip";
$target_fn = "test.txt";
$command = 'c:\xampp\mysql\bin\mysqldump -u'.$_user.' -p'.$_pass.' -
h'.$_host." ".$_db.' > test.txt';
try{
exec( $command );
}
catch(Exception $e){
echo $e;
}
?>
EDIT
I"m on a XAMPP stack.
EDIT After running the above command on a cmd, i realized it still prompts for a password. Perhaps an empty password is what the command is misinterpreting wrongly.
So the problem was the command syntax/structure for a blank password. Here is the correct command for a blank pass:
$command = 'C:\xampp\mysql\bin\mysqldump -u'.$_user.' -h'.$_host." ".$_db.' > test.txt';
$return_var = NULL;
$output = NULL;
$command = "/usr/bin/mysqldump -u mysql-user -h 123.145.167.189 -pmysql-pass database_name > /path-to-export/file.sql";
exec($command, $output, $return_var);
Try giving 2 more parameters to the exec
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.