Find the host name of the mysql connection in PHP

In cases where I need to find the host name, I use the following mysql query. Here is how you can use it in your PHP application and quickly find out the mysql hostname.
<?php
$sql = "SHOW VARIABLES WHERE Variable_name = 'hostname'";
$qdata = mysql_query($sql);
print_r(mysql_fetch_array($qdata)); // prints debug.
?>
$sql = "SHOW VARIABLES WHERE Variable_name = 'hostname'";
$qdata = mysql_query($sql);
print_r(mysql_fetch_array($qdata)); // prints debug.
?>
Now you can easily connect to the mysql database with your favorite database client.
Please feel free to leave a comment if this article was helpful to you :)
Please feel free to leave a comment if this article was helpful to you :)
0 comments :
Post a Comment