Reputation: 9721
I want to back up and roll back the back up on a database, and I'm trying to see what's wrong:
'mysqldump' is not recognized as an internal or external command, operable program or batch file.
The above is what I get in the file that is exported. And this is what I run:
$database = 'logindb';
$backup = $location.'/'.$database.'_backup_'.date('Y').'_'.date('m').'_'.date('d').'.sql';
exec("mysqldump --opt -h localhost -u root logindb > $backup 2>&1", $output);
print_r($output);
As $location
being my backup folder. So why do I get that error ?
And as additional info, I'm testing on localhost with XAAMP, the Apache server is running and MySQL is running as wel.
Upvotes: 1
Views: 7098
Reputation: 51715
Because mysqldump
is not in httpd user path.
I asume you work in Linux (or UNIX).
To know witch directory contains mysqldump
you can execute whereis mysqldump
.
Then you have two options:
Check for mysqldump directory is in PATH environment variable of httpd user (usualy www-data
user for apache server). And include it in PATH is it not present.
Also you can execute mysqldump
with full path:
Like this:
exec("/path_to_mysql_bins/mysqldump ...
Upvotes: 3
Reputation: 2493
The error is not a mysqldump error, it's a Windows error that says that it does not understand what mysqldump
relates to. To fix that you can either include the path to mysqldump executable to the environment variables or run the exec command with a full path to the mysqldump executable (which you can find within XAMPP mysql folder).
Upvotes: 1