그래서 나는/백업 MySQL의 명령을 실행하여 데이터베이스를 복원하기 위해 PHP를 사용하고 있습니다. 로컬 호스트에서 실행 파일을 정확히 찾아야했기 때문에 문제없이 작동했습니다. 그러나 서버에서는 작동하지 않습니다.MySql 명령어 mysqldump가 실행되지 않습니까?
는public function backup() {
$backup = $this->backups.'/'.$this->db_name.'_backup_'.date('Y').'_'.date('m').'_'.date('d').'.sql';
$cmd = "mysqldump --opt -h $this->db_host -p $this->db_pass -u $this->db_user $this->db_name > $backup";
try {
system($cmd);
return $this->encode('Error',false,'Backup Successfuly Complete');
} catch(PDOException $error) {
return $this->encode('Error',true,$error->getMessage());
}
}
public function restore($backup) {
$cmd = "mysql --opt -h $this->db_host -p $this->db_pass -u $this->db_user $this->db_name < $backup";
try {
exec($cmd);
return $this->encode('Error',false,'Restore successfuly complete');
} catch(PDOException $error) {
return $this->encode('Error',true,$error->getMessage());
}
}
내가 서버에 작업 명령이 아닌 이유 알아 찾고 있어요, 거기에 어떤 변수의 추상화를 확인하십시오 : 이것은 내가 PHP 코드로 사용하고 있습니다 것입니다. 명령이 실제로 제대로 실행 된 경우에도
어떻게 PHP로 확인합니까? try
방법으로 나는 항상 긍정적 인 대답을 얻습니다.
는 서버에서 적절한 쓰기 권한이 있습니까? –
는 $ cmd를 값을 인쇄하고 .. – barsju
@barsju을 서버에서 수동으로 실행하고 여기에 오류 메시지를보고하려고 - 당신은 phpMyAdmin을에 의미? 나는 그것을 거기에서 실행하려고 할 것이고, 무엇이 일어날 것인지에 관해 알 것이다. – Roland