How to get server MySQL version in PHP without connecting

Problem :

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?

Solution :

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][email protected]', $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 Tutorials

Mysql Howto..

MYSQL/PHP - How to make a “Sort By” dropdown for sorting results drawn from mysql

How to store precise decimal degree coordinates in a MySQL database

How to optimize a MySQL table? [duplicate]

How to select all records that are 10 minutes within current timestamp in MySQL?

How to get search a column name from a MySQL database? [duplicate]

how to send mail from mysql using stored-procedures?

how to use MySQL bitwise operations in php?

How to sort data with a case statement - using MySQL?

How to ensure connection.end() is called when obtaining a database connection from a pool

Any Mysql guru who knows how to handle a custom group calculation scenario in 1 query?

How to get the date value in the table in specific format?

How to Handle Multiple MySQL Operations in PHP if One Fails

How to insert current date into mysql db using java

How do I use MacPorts to downgrade a dynamic library?

How to check a checkbox querying MySQL which record is boolean

How to get the last field in a Mysql database with PHP?

How to update one table in MySQL after insertion in another table

How to update data from localhost MySQL server to remote MySQL server

How to count the total items under the parent sub category in mysql

How to get the First and Last Row Numbers of Four Rows to be Displayed

How to efficiently store AWS machine IDs in Db

How to retrieve objects from a MySQL Database with a many-to-many relationship?

How can I select tags from MySQL sorted by creation_date and name but remove duplicate name?

How to optimize this Mysql query

How to delete a row where there are only one of the kind in MySql?

How does privilege users work on MySQL?

How to select data from multiple tables using joins/subquery properly? (PHP-MySQL)

How to maintain a certain number of rows using triggers in MySQL?

How to store distances between places?

How to know how many mysql lines updated