我无法找到任何其他路径,除了你在问题中给出的路径。然而,我想到的一件事是在大多数情况下,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 –