久々にMySQLを起動しようと思ったら以下のようなエラーが出て起動できなかったときの対処法をメモしておきます。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mysql.server start | |
Starting MySQL | |
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Air.local.pid). |
環境
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- macOS Mojave 10.14.4 | |
- MySQL 8.0.15 |
対処法
結論から言うと、以下コマンドで解決しました。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQLのデータファイルやログなどが格納されているディレクトリを削除する | |
$ sudo rm -rf /usr/local/var/mysql | |
# MySQLを再インストール | |
$ brew uninstall mysql | |
$ brew install mysql | |
# MySQLを起動 | |
$ mysql.server start | |
Starting MySQL | |
SUCCESS! |
同じように困っている方の記事を参考に、MySQLのエラーログ(/usr/local/var/mysql/MacBook-Air.local.err
)を確認したり、単にMySQLを再インストールしたりしたのですが解決しませんでした。結局、MySQLのデータファイルやログなどが格納されているディレクトリ(/usr/local/var/mysql
)をごそっと削除して、MySQLを再インストールしたらうまくいきました。
注意点として、/usr/local/var/mysql
ディレクトリを削除することになるので、MySQLで作成したデータベースやテーブルがすべて削除されます。「MySQLのデータを削除したくない!」という方には、本手順はおすすめしません。
まとめ
「ERROR! The server quit without updating PID file」でMySQLが起動できないときの対処法でした。多少荒っぽいやり方ですが、ちょこっとSQLを試してみたい僕としては起動させすればいいのです。