I need to echo the MySQL version in a PHP script (it's a server requirement check page for users before downloading the plugin) without having them connect to their database.
The upload this script to their server and open it in the browser. I could ask them to run php info but all I need is the Mysql version and it gets formatted in the script with the rest of the results.
How should i go about this?
If you have access to the command line mysql executable you can try this:
function getMySQLVersion() {
$output = shell_exec('mysql -V');
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
return $version[0];
}
For the client version:
print mysql_get_client_info();
Without shell access to get the server version you must connect first:
$link = mysql_connect("localhost", "username", "password");
if (!$link) die('Could not connect: ' . mysql_error());
print "MySQL server version: " . mysql_get_server_info();
mysql_close($link);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With