I'm working on a project and I'm playing around with the maintenance ability to dump and restore a database to work with early git development. My database will be changing a lot so I need a simple way to track this for now. Probably not the worlds best solution, but for the moment, this is a nice way to handle it.
So my problem is that I can't get mysqldump to connect.
I'm borrowing code from another post here: mysqldump via PHP
$command = "/usr/bin/mysqldump -u ".$database_user." -h ".$database_host." -p".$database_password." ".$database." > ".SERVER_PATH."data/testing.sql";
exec($command, $output, $return_var);
if($return_var !== 0) {
$theTruth = "mysqldump for {$database_host} : {$database} failed with a return code of {$return_var}<br><br>\n\n";
$theTruth .= "Error message was:<br>\n";
$file = escapeshellarg("mysqldump_error.log");
$message = `tail -n 1 $file`;
$theTruth .= "- $message<br><br>\n\n";
$theTruth .= "Exec: $command<br><br>\n\n";
return $theTruth;
}
This has been returning an error message of 2: indicates "not found". The problem I'm hitting though, I can use this exact same command from the terminal and it works 100% as expected.
Edit
Using passthru instead of exec didn't reveal anything new.
I also spit out the exec command to the browser to make sure it was being processed correctly. Here's a modified version (for security purposes)
/usr/bin/mysqldump -u username -h localhost -ppass databasename > /path/to/save/every/thing/testing.sql
I'm not sure what's preventing this.