Show MySQL Host via SQL Command



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

Query 1

The following is the query to display the host ?

mysql > select @@hostname;

Output

Here is the output ?

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

Query 2

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

show variables where Variable_name like '%host%';

Output

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: 2024-12-24T17:56:34+05:30

31K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements