Show MySQL host via SQL Command?


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)

Updated on: 14-Sep-2023

25K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements