วิธีติดตั้ง MySQL Command Line Client บน Windows
ขั้นตอนการดาวน์โหลด
- เข้าเว็บไซต์ ufficiale: https://dev.mysql.com/downloads/mysql/
- เลือก Operating System: Windows (x86, 32/64-bit)
- เลือกประเภท Installer:
- Web Installer (mysql-installer-web-community) - ไฟล์เล็ก ดาวน์โหลดส่วนประกอบตอนติดตั้ง
- Full Installer (mysql-installer-community) - ไฟล์ใหญ่ ครบหมดในไฟล์เดียว (แนะนำสำหรับ Offline)
- คลิก Download (อาจต้อง Login Oracle Account หรือคลิก "No thanks, just start my download")
- รันไฟล์ .msi ที่ดาวน์โหลดมา
การติดตั้ง (Installation Wizard)
- เลือก Setup Type: Developer Default (ครบเครื่อง), Server Only, Client Only, Custom
- ติดตั้ง Components ที่ขาด (Visual C++ Redistributable, Python ฯลฯ)
- ตั้งค่า Root Password และ Authentication Method (Strong Password Encryption แนะนำ)
- ตั้งค่า Windows Service: Service Name, Port (Default 3306), Start at Boot
- Apply Configuration → Finish
การใช้งาน Command Line Client
หลังติดตั้งเสร็จ จะมี 2 ทางเข้าหลัก:
- MySQL 8.0 Command Line Client - โปรแกรม Console แยกต่างหาก (Start Menu → MySQL → MySQL 8.0 Command Line Client)
- Windows Command Prompt / PowerShell - พิมพ์
mysql -u root -p(ต้องเพิ่ม Path ใน Environment Variables)
เพิ่ม MySQL เข้า PATH (ถ้ายังไม่มี)
setx PATH "%PATH%;C:\Program Files\MySQL\MySQL Server 8.0\bin"
หรือเพิ่มผ่าน GUI: System Properties → Environment Variables → Path → Edit → New
ทดสอบการเชื่อมต่อ
mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor...