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

MySQL Server Port Number (ค่าเริ่มต้น 3306)

Port เริ่มต้น

MySQL ใช้ Port 3306 เป็นค่าเริ่มต้น

ตรวจสอบด้วยคำสั่ง

mysql> SHOW VARIABLES WHERE Variable_Name = 'port';
+---------------+-------+
| Variable_Name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.04 sec)

เปลี่ยน Port

  1. แก้ไข my.ini (Windows) หรือ my.cnf (Linux)
  2. ใน Section [mysqld] เพิ่ม/แก้: port = 3307
  3. Restart MySQL Service

เชื่อมต่อ Port ที่ไม่ใช่ 3306

mysql -h host -P 3307 -u user -p

(สังเกต: -P ตัวใหญ่สำหรับ Port, -p ตัวเล็กสำหรับ Password)