Page 1 of 1

Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 11:11 am
by kaisellgren
Hi,

Does anyone have a solution to find out the installed MySQL version without the connection details? Maybe by reading some specific files?

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 12:30 pm
by requinix
Can always do

Code: Select all

$ mysqld --version

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 12:33 pm
by mikemike
If you have commandline/SSH access you can just do `mysql -V`

Code: Select all

[root@mike-hub httpdocs]# mysql -V
mysql  Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 12:45 pm
by iFlex

Code: Select all

<?php
 
//Call to discover PHP information on your server.
phpinfo();
 
?>
 
Should do the trick, just search for the MySQL bit.

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 1:06 pm
by McInfo
This is a pretty dirty way of doing it, but it works on Windows and should work on Unix.

Code: Select all

<?php
function get_mysql_version ()
{
    ob_start();
    phpinfo(INFO_MODULES);
    preg_match('#<td class="e">Client API version </td><td class="v">([0-9.]+) </td>#', ob_get_contents(), $matches);
    ob_end_clean();
    return isset($matches[1]) ? $matches[1] : false;
}
echo 'MySQL Version: '.get_mysql_version();
?>
Edit: This post was recovered from search engine cache.

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 1:13 pm
by kaisellgren
It was simpler then I thought: mysqli_get_client_info(); :D

Re: Find out MySQL version without the database details?

Posted: Thu Jun 04, 2009 1:19 pm
by McInfo
I overlooked that one because I saw that both mysql_get_host_info() and mysql_get_server_info() have a link resource parameter. Haste makes waste, I guess.

Edit: This post was recovered from search engine cache.