##環境
mysql 8.0
Catalina 10.15.6
##遭遇したエラー
~ ❯❯❯ mysql -u user(ユーザー名) -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
当然、ルートでも入ることできず。
~ ❯❯❯ mysql -u root -p ✘ 1
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
内容的にはpidファイルがアクセス拒否で削除できないと怒ってる模様。
サイトを参考にしながら下記の手順で行ってみました。
~ ❯❯❯ mysql.server restart ✘ 1
touch: /usr/local/var/mysql/ユーザー名.pid.shutdown: Permission denied
cat: /usr/local/var/mysql/ユーザー名.pid: Permission denied
ERROR! MySQL server process # is not running!
override rw-r----- _mysql/_mysql for /usr/local/var/mysql/ユーザー名.pid?
Starting MySQL
SUCCESS!
~ ❯❯❯ /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
cat: /usr/local/var/mysql/ユーザー名.pid: Permission denied
rm: /usr/local/var/mysql/ユーザー名.pid: Permission denied
2020-09-13T09:14:24.6NZ mysqld_safe Fatal error: Can't remove the pid file:
/usr/local/var/mysql/ユーザー名.pid.
Please remove the file manually and start /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe again;
mysqld daemon not started
/usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
自らの手で削除してあげる。
~ ❯❯❯ sudo rm /usr/local/var/mysql/ユーザー名.pid. ✘ 1
Password:
rm: /usr/local/var/mysql/ユーザー名.pid.: No such file or directory
~ ❯❯❯ sudo rm /usr/local/var/mysql/ユーザー名.pid ✘ 1
サーバーの立ち上げをしてみましたが、エラーが出ました。
~ ❯❯❯ mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL
./usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
/usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
/usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 199: /usr/local/var/mysql/ユーザー名.err: Permission denied
/usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/var/mysql/ユーザー名.pid).
今度はpidファイルがないと怒ってるので作成してあげる。
その上でchmodコマンドで権限も弄りましたが、これは考えなしにやってるので必要なければ必要はないと思います。
~ ❯❯❯ sudo touch /usr/local/var/mysql/ユーザー名.pid
~ ❯❯❯ sudo chmod 777 /usr/local/var/mysql/ユーザー名.pid
再度サーバーを立ち上げ直す
~ ❯❯❯ mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL
./usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
rm: /usr/local/var/mysql/ユーザー名.pid: Permission denied
2020-09-13T09:19:00.6NZ mysqld_safe Fatal error: Can't remove the pid file:
/usr/local/var/mysql/ユーザー名.pid.
Please remove the file manually and start /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe again;
mysqld daemon not started
/usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/ユーザー名.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/var/mysql/ユーザー名.pid).
~ ❯❯❯ sudo mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL
.. SUCCESS!
お疲れ様でした!!
##参考にさせていただいたサイト
https://qiita.com/carotene4035/items/e00076fe3990b9178cc0