Reputation: 3151
I've tried to backup my database with the following php code on mac Sierra:
$command = "mysqldump --opt -u root -proot si_clinic_pos > clinic.sql";
system($command, $output);
if($output != 0) {
echo $output;
}else {
echo 'Database saved';
}
The output is "127", but if I tried to execute the "mysqldump --opt -u root -proot si_clinic_pos > clinic.sql" inside terminal, it's working fine.
what's wrong with it, could you please help me?
Upvotes: 0
Views: 2561
Reputation: 3038
The solution to the problem is to specify the full path to the executable file you want to run.
So, in this specific case, instead of:
$command = "mysqldump ...";
you need to have:
$command = "/usr/bin/mysqldump ...";
Upvotes: 3
Reputation: 26
/bin/sh could not be executed, the exit status will be that of a command that does exit(127).I advice you run your PHP program as root user.
Upvotes: 0