LoginSignup
0
1

More than 3 years have passed since last update.

mysqlが起動しない

Last updated at Posted at 2019-06-17

業務ではdockerを用いててたけど、プライベートで開発しようとした時にmysqlでえらい詰まったのでメモ

悩まされていたエラー

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)
ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxxxxxx.ftth.ucom.ne.jp.pid).

他の記事で原因としてよく挙げられていたのが以下であった
・ mysql.serverを起動していなかった
・ 必要なファイルの権限が正しくなかった

確認したこと
・/tmp/mysql.sockがあるかどうか → ある
・/tmp/mysql.sockの権限 → _mysql(mysqlの実行ユーザーなので正しい)
・export PATH="/usr/local/opt/mysql@5.7/bin:$PATH" がbash_profileに記述されているか => パスは通っていて呼びだせる
mysqld_safeを起動できるか -> できない

結論
- 1. mysqlをアンインストール

brew uninstall mysql@5.7
  • 2. アンインストール後も /usr/local/var/mysql 以下の関連のファイルが削除されていなかったため削除
sudo rm -rf /usr/local/var/mysq
  • 3.再インストール
$ brew install mysql@5.7
  • 4. sockを再作成、権限を変更
$ touch /tmp/mysql.sock
$ chown _mysql /tmp/mysql.sock
  • 5. 新しく作成された関連ファイルの権限が自分になっていたので_mysqlに変更
$ sudo chown -R _mysql:_mysql /usr/local/var/mysql 

これで動いた

参考
https://qiita.com/_natsu_no_yuki_/items/ae4c94187093e4ab3cdc

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1