WP_CLI\Utils

get_mysql_version()WP-CLI 1.0

Get the version of the MySQL database.

No Hooks.

Return

String. Version of the MySQL database, or an empty string if not found.

Usage

get_mysql_version();

get_mysql_version() code WP-CLI 2.7.0-alpha

function get_mysql_version() {
	static $version = null;

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

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

	return $version;
}