Josh
Josh

Reputation: 690

How to detect the mySQL version using PHP?

I can use:

extension_loaded('mysql')

to check if mySQL is installed on the server or not.

also phpinfo() can display a nice phpinfo page.

but how to get which mysql version is installed on server? is there any function like:

which_extension_version('mysql') //output the mysql version?

just like the PHP_VERSION?

Upvotes: 0

Views: 1112

Answers (3)

Emil
Emil

Reputation: 1816

Take a look at: mysql_get_server_info()

Upvotes: 0

Nambi
Nambi

Reputation: 12042

Use the mysql_get_server_info() after connect with mysql_connect

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
printf("MySQL server version: %s\n", mysql_get_server_info());
?>

Upvotes: 1

gbestard
gbestard

Reputation: 1177

You can get it with:

mysqli_get_server_version();

Upvotes: 2

Related Questions