首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

MySQL 服務啟動報錯 1067 根因排查:端口佔用與進程衝突實戰

     編輯:MySQL 資料庫相關知識

錯誤現象

Windows could not start the MySQL service on Local Computer.
Error 1067: The process terminated unexpectedly.

排查實戰:netstat 定位端口佔用

# 查看 3306 端口佔用情況
netstat -aon | findstr "3306"

# 輸出示例
TCP    0.0.0.0:3306    0.0.0.0:0    LISTENING    416
# PID 416 佔用了 3306 端口

定位佔用進程

tasklist | findstr "416"

# 輸出示例
explorer.exe      416  Console  1  12,345 K
# 驚人發現:explorer.exe (資源管理器) 佔用了 3306!

根因分析

安裝了優酷/迅雷等 P2P 加速軟件,其內嵌組件劫持系統進程 (explorer.exe/svchost.exe) 監聽常用端口 (3306, 80, 443 等) 用於 P2P 傳輸,導致正規服務無法綁定端口。

解決方案

  1. 終止佔用進程
    taskkill /PID 416 /F
    # explorer.exe 會自動重啟,但重啟後通常不再佔用 3306
  2. 配置加速軟件:設置「不隱藏任務欄圖標」「開機不自動啟動」「不佔用常用服務端口」
  3. 修改 MySQL 端口 (備選):my.ini 中 port=3307,但需同步修改所有客戶端連接配置

驗證啟動

net start mysql
# The MySQL service is starting.
# The MySQL service was started successfully.

預防清單

  • 服務器禁裝 P2P/加速/下載類軟件
  • 核心服務端口 (3306, 5432, 6379, 27017 等) 加入防火牆白名單並監控佔用
  • 部署腳本中添加 netstat -an | findstr PORT 預檢步驟
  • 生產環境 MySQL 建議修改非默認端口 + 防火牆限制訪問源 IP

總結

Error 1067 多為「進程意外終止」,Windows 下 90% 由端口佔用引起。netstat -aon | findstr PORT → tasklist | findstr PID → taskkill /F 三步法可快速定位解決。服務器環境純淨化是根治之道。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved