Show MySQL host via SQL Command?

MySQLMySQLi Database

To display MySQL host via SQL command, use system variable “hostname”.

The following is the query to display the host −

mysql> select @@hostname;

Here is the output −

+-----------------+
| @@hostname      |
+-----------------+
| DESKTOP-QN2RB3H |
+-----------------+
1 row in set (0.00 sec)

Or you can use “show variables” command to show MySQL host via SQL command.

show variables where Variable_name like '%host%';

The following is the output −

+-------------------------------+-----------------+
| Variable_name                 | Value           |
+-------------------------------+-----------------+
| host_cache_size               | 279             |
| hostname                      | DESKTOP-QN2RB3H |
| performance_schema_hosts_size | -1              |
| report_host                   |                 |
+-------------------------------+-----------------+
4 rows in set (0.07 sec)
raja
Published on 21-Dec-2018 17:23:48
Advertisements