You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

XAMPP中MySQL端口被阻塞:更换端口后问题仍存在

Troubleshooting MySQL Port Block Issue in XAMPP

Let me walk you through some practical, step-by-step checks to resolve this port blocking problem you’re stuck with:

1. Confirm if Port 3308 is Actually Occupied

First, we need to pinpoint exactly what’s holding onto port 3308 (if anything):

  • Windows: Open Command Prompt as Administrator and run:
    netstat -ano | findstr :3308
    
    Note the PID number in the last column, then open Task Manager > Details tab, find that PID, and end the process. It’s often a leftover MariaDB/MySQL service from your messy first installation that didn’t fully shut down.
  • macOS/Linux: Open Terminal and run:
    lsof -i :3308
    
    Use kill -9 <PID> to force-stop the conflicting process.

2. Double-Check All MySQL Port Configurations

Make sure your port change is applied everywhere it needs to be:

  • Open the my.ini (or my.cnf) file in your XAMPP MySQL directory. Confirm you’ve set:
    port=3308
    bind-address=127.0.0.1
    
    Save and close the file.
  • Launch the XAMPP Control Panel:
    • Click the "Config" button next to MySQL, select "my.ini" to re-verify the port setting.
    • Go to "Service and Port Settings" > "MySQL" tab, ensure the port is set to 3308, save changes, then restart the XAMPP MySQL service.

3. Clean Up Leftover System Services (Windows Only)

Previous MySQL/MariaDB installs might have left behind system services that are still hogging resources:

  • Press Win + R, type services.msc, and hit Enter.
  • Look for any services named "MySQL" or "MariaDB". If found, right-click to stop them, set their startup type to "Disabled", and even delete them via admin Command Prompt:
    sc delete <ServiceName>
    

Restart your computer to clear any lingering processes, then try starting XAMPP’s MySQL again.

4. Test a Direct Connection to Port 3308

Narrow down the issue by connecting directly via the command line:

  • Open XAMPP’s Shell (click the "Shell" button in the control panel) and run:
    mysql -u root -P 3308 -p
    

A "Connection refused" error means MySQL isn’t listening on 3308 at all; a timeout points to firewall interference.

5. Check Firewall and Antivirus Settings

Windows Firewall or third-party antivirus often blocks new ports:

  • Temporarily disable your firewall/antivirus and try starting MySQL again. If it works, add an inbound/outbound rule for port 3308 to allow MySQL traffic.
  • Ensure the rule covers both TCP and UDP protocols, and explicitly includes the XAMPP MySQL executable (mysqld.exe in xampp/mysql/bin).

内容的提问来源于stack exchange,提问作者FerrisDale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:23:33