WP_CLI\Utils

get_mysql_binary_path()WP-CLI 1.0

Get the path to the mysql binary.

No Hooks.

Return

String. Path to the mysql binary, or an empty string if not found.

Usage

get_mysql_binary_path();

get_mysql_binary_path() code WP-CLI 2.7.0-alpha

function get_mysql_binary_path() {
	static $path = null;

	if ( null === $path ) {
		$result = Process::create( '/usr/bin/env which mysql', null, null )->run();

		if ( 0 !== $result->return_code ) {
			$path = '';
		} else {
			$path = trim( $result->stdout );
		}
	}

	return $path;
}