MySQL ใช้ Port Number 3306 ตามค่าเริ่มต้น
Port 3306
- ใช้โดย MySQL Protocol เชื่อมต่อ Clients และ Utilities (mysqldump ฯลฯ)
- เป็น TCP (Transmission Control Protocol)
ช่องโหว่ด้านความปลอดภัย
- Port 3306 ไม่ควรเปิดเผยต่อ Public Internet (Vulnerable to Attacks)
- ต้องการ Remote Access -> ใช้ SSH Tunnel แทน
- หากบังคับเปิด -> จำกัด IP Addresses ที่เข้าถึงได้ (Firewall/Whitelist)
- Port 3306 เป็นค่าเริ่มต้น แต่ MySQL อาจใช้ Port อื่นได้
ตรวจสอบ Port ที่ใช้งานจริง
SHOW VARIABLES WHERE Variable_name = 'port';
แนวทางปฏิบัติที่ดี
- ไม่เปิด Port 3306 ต่อ Internet โดยตรง
- ใช้ VPN หรือ SSH Tunnel สำหรับ Remote Access
- Bind Address ให้เฉพาะ Interface ที่จำเป็น (
bind-address=127.0.0.1สำหรับ Local Only) - ใช้ SSL/TLS สำหรับการเชื่อมต่อที่เข้ารหัส
- เปลี่ยน Port เริ่มต้นเพื่อลด Automated Attacks (Security through Obscurity)