XAMPPでMySQL起動できないときの対処法(MySQL shutdown unexpectedly)

XAMPPでローカルでWordPress使ってるとき、MySQL起動できなかったので、その対処法をメモしておきます。

 

エラーは以下のような内容です

 

f:id:success-seed:20200417102858p:plain

Error: MySQL shutdown unexpectedly.This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method.Press the Logs button to view error logs and checkthe Windows Event Viewer for more clues if you need more help, copy and post this entire log window on the forums

 

ログ見るように言われたので、見てみたけど、よくわからない

と思って、もう少し前の出力内容見てみたら、ポートが使用中でうまくいってないみたい。

f:id:success-seed:20200417104342p:plain

Port 3306 in use by "Unable to open process"!MySQL WILL NOT start without the configured ports free! You need to uninstall/disable/reconfigure the blocking application or reconfigure MySQL and the Control Panel to listen on a different port

 

ということなので、使用中の3306ポートを強制的に終了して、もう一回スタートさせます。

 

ちなみにWindowsでのやり方です。

まずは、コマンドプロンプト開くときに右クリックで管理者権限で実行します

f:id:success-seed:20200417105526p:plain

すると、コマンドプロンプト開くので、

 

netstat -aon | find "[探したいポート番号]"
taskkill /f /pid [終了させたいPID]

 

を実行します。

まずは、

netstat -aon | find "[探したいポート番号]"

ですが、

[探したいポート番号]は、私の場合3306です

すると

 

TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 5700

 

みたいに表示されます

5700がPIDにあたるので、

taskkill /f /pid 5700

で終了させます。

 

以上の操作をした後、もう一度XAMPPのMySQLのStart押すと、

無事立ち上がるはずです。

 

これで、ようやく、開発のスタート地点に立てたー