How To Get Some Basic Information Back from MySQL Servers

Q

How To Get Some Basic Information Back from MySQL Servers? - MySQL FAQs - PHP Connections and Query Execution

✍: FYIcenter.com

A

Once you got a MySQL server connection object successfully, you can use mysql_get_server() and mysql_get_host_info() to get some basic information from your MySQL server. The tutorial exercise below is a good example:

<?php
  $con = mysql_connect('localhost:8888', 'dev', 'iyf');
  if (!$con) {
    print("There is a problem with MySQL connection.\n");
  } else {
    print("The MySQL connection object is ready.\n");
    print(mysql_get_client_info()."\n");
    print(mysql_get_server_info($con)."\n");
    print(mysql_get_host_info($con)."\n");
    mysql_close($con); 
  }
?>

If you run this script, you will get something like this:

The MySQL connection object is ready.
4.1.7
5.0.24-community-log
localhost via TCP/IP

2007-05-10, 5169👍, 0💬