Ich konnte keine anderen Pfade finden als die, die Sie in Ihrer Frage angegeben haben. Eine Sache, die mir in den Sinn kommt, ist, dass sich mysqldump
in den meisten Fällen im gleichen Verzeichnis wie die mysql
Binärdatei befinden sollte. Jetzt wird der Befehl mysql
in den meisten Fällen auch im Pfad enthalten sein.
Und deshalb können Sie die beiden Logiken kombinieren, um die Position des mysqldump
binär haben, in den meisten Fällen wie folgt aus:
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);
}
Jetzt können Sie die obige Funktion für Ihre Zwecke verwenden. Und stellen Sie eine Möglichkeit für den Benutzer bereit, den expliziten Pfad zu mysqldump
manuell bereitzustellen, wenn die obige Funktion einen Fehler auslöst. Sollte für Ihre Anwendungsfälle funktionieren :)
Haben Sie versucht, 'find/-name mysqldump -type f -perm/u = x' beim ersten Lauf auszuführen, dann den Wert in einer Datei zwischenspeichern? –
Ich habe es nicht versucht. Ich habe das gerade auf meinem Mac gemacht und habe 'find: -perm:/u = x: illegaler Modus string' –
Sieht aus wie eine alte Version von find, probiere -perm/u + x oder -perm/444 oder sogar älter -perm +444 –