LoginSignup
1
1

More than 5 years have passed since last update.

Macを再起動したらMySQLが動かなくなったので頑張った

Posted at

たぶんありがちな話。

でも似たような話がいろいろ転がっていて、どれが自分の症状なのかよくわからなかったので手間取ったorz

現象

  1. なんかMac重いなーと思って再起動
  2. 再起動完了!さー開発するぞ
  3. あれ?ローカル開発環境立ち上がらない・・・
  4. MySQLにログインできない・・・だと・・・😂

症状

これで落ちてた。なんでだ。

ERROR 1045 (28000): Access denied for user 'root'@'localhost'

環境

OS: macOS High Sierra 10.13.6
MySQL: 5.7.19

解決

事象が起こった要因は結局よくわからなかったが、自分の場合は下記をやることで解決した

そもそもなんで怒られてるのか

Access deniedなので、まあ権限まわりがおかしくなっているんでしょうと推測

であれば、権限なしでも使えるようにしてやればよい

mysqlを止める

sudo mysql.server stop

権限なしで動かせるようにする

sudo mysqld_safe --skip-grant-tables &

mysqlにログイン

mysql -u root

mysql db の users table をチェック

select host, user, authentication_string from user;

passってなんぞ。。。

+-----------+---------------+-------------------------------------------+
| host      | user          | authentication_string                     |
+-----------+---------------+-------------------------------------------+
| localhost | root          | pass                                      |
| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+---------------+-------------------------------------------+

消したれ

update user set authentication_string = null where user = 'root'

通常モードで起動し直す

sudo mysql.server stop
sudo mysql.server start

入れた

$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19 Homebrew

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

まとめ

よくわからず使っているのは良くないなと思いました。
ちゃんと勉強しよう。。

1
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
1
1