我無法找到任何其他路徑,除了你在問題中給出的路徑。然而,我想到的一件事是在大多數情況下,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);
}
,您可以用上面的功能爲您的目的。並且,如果上述函數引發錯誤,則爲用戶提供一種手動提供mysqldump
二進制文件的顯式路徑的方法。應該爲你的用例工作:)
您是否嘗試在第一次運行時運行'find/-name mysqldump -type f -perm/u = x',然後將值緩存在文件中? –
我還沒試過。我只是在我的Mac上做了這個,得到了'find:-perm:/ u = x:非法模式字符串' –
看起來像舊版本的find,嘗試-perm/u + x或-perm/444甚至更老的-perm +444 –