질문에서 다른 경로를 찾을 수 없었습니다. 그러나, 내 마음에 오는 한 가지는 mysqldump
은 대부분 mysql
바이너리와 같은 디렉토리에 있어야한다는 것입니다. 이제 대부분의 경우 mysql
명령이 경로에 표시됩니다.
그리고, 따라서이 같은, 대부분의 경우 mysqldump
바이너리의 위치를 가지고 두 개의 논리를 결합 할 수 있습니다 :
function detect_mysqldump_location() {
// 1st: use mysqldump location from `which` command.
$mysqldump = `which mysqldump`;
if (is_executable($mysqldump)) return $mysqldump;
// 2nd: try to detect the path using `which` for `mysql` command.
$mysqldump = dirname(`which mysql`) . "/mysqldump";
if (is_executable($mysqldump)) return $mysqldump;
// 3rd: detect the path from the available paths.
// you can add additional paths you come across, in future, here.
$available = array(
'/usr/bin/mysqldump', // Linux
'/usr/local/mysql/bin/mysqldump', //Mac OS X
'/usr/local/bin/mysqldump', //Linux
'/usr/mysql/bin/mysqldump' //Linux
);
foreach($available as $apath) {
if (is_executable($apath)) return $apath;
}
// 4th: auto detection has failed!
// lets, throw an exception, and ask the user to provide the path instead, manually.
$message = "Path to \"mysqldump\" binary could not be detected!\n"
$message .= "Please, specify it inside the configuration file provided!"
throw new RuntimeException($message);
}
지금, 당신은 당신의 목적을 위해 위의 기능을 사용할 수 있습니다. 위의 함수가 오류를 throw하면 사용자가 mysqldump
바이너리에 명시 적 경로를 수동으로 제공 할 수있는 방법을 제공하십시오. 당신의 유스 케이스를 위해 일해야한다 :)
처음 실행했을 때'find/-name mysqldump -type f -perm/u = x'를 실행 해 보았습니까? –
나는 시도하지 않았다. 나는 단지 Mac에서 이것을 실행하고'find : -perm :/u = x : 불법적 인 모드 문자열 '을 얻었습니다. –
find의 이전 버전처럼 보입니다. -perm/u + x 또는 -perm/444 또는 더 오래된 -perm +444 –