Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

วิธีดู MySQL Host ผ่าน SQL Command

วิธีที่ 1: ใช้ @@hostname

mysql> select @@hostname;
+-----------------+
| @@hostname      |
+-----------------+
| DESKTOP-QN2RB3H |
+-----------------+
1 row in set (0.00 sec)

วิธีที่ 2: ใช้ SHOW VARIABLES

SHOW VARIABLES WHERE Variable_name LIKE '%host%';
+-------------------------------+-----------------+
| Variable_name                 | Value           |
+-------------------------------+-----------------+
| host_cache_size               | 279             |
| hostname                      | DESKTOP-QN2RB3H |
| performance_schema_hosts_size | -1              |
| report_host                   |                 |
+-------------------------------+-----------------+
4 rows in set (0.07 sec)

คำอธิบาย

  • @@hostname: ชื่อ Host ของ Server MySQL (สั้นเร็ว)
  • SHOW VARIABLES LIKE '%host%': ดูตัวแปรทั้งหมดเกี่ยวกับ Host รวมถึง cache size, performance schema