LoginSignup
9
9

More than 5 years have passed since last update.

mysql5.7が急に起動しなくなった

Posted at

症状1

  • 次のようなエラーが出て、mysqldが起動出来ない
    • [ERROR] /usr/sbin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
    • [ERROR] Can't start server: can't create PID file: No such file or directory
  • /var/run 配下にmysqldというディレクトリがなかった。

対応

# mkdir /var/run/mysqld
# chown mysql:mysql /var/run/mysqld
# service mysqld start

これでOKです。

症状2

プラグインが読み込めないとかでログイン出来ない

2016-09-19T01:57:08.882670Z 0 [Warning] Failed to open optimizer cost constant tables

2016-09-19T01:57:08.891601Z 0 [Warning] The plugin '*151C1A8D637C2F25287AA421FF8D6AFEFBDDE9B1' used to authenticate user '{ユーザ名}'@'localhost' is not loaded. Nobody can currently login using this account.

対応

とりあえずrootでログインします。

$ mysql -u root -p
mysql> use mysql;
mysql> select * from user where User = "{ユーザ名}";

*************************** 1. row ***************************
                  Host: localhost
                  User: {ユーザ名}
                  ...
                  plugin: 151C1A8D637C2F25287AA421FF8D6AFEFBDDE9B1
                  ...


-- このpluginというカラムが、`mysql_native_password`になってないのが原因です。
-- まずはpluginの部分を直しましょう。

mysql> update user set plugin = 'mysql_native_password' where User = "{ユーザ名}";
-- この状態でパスワードの変更をしようとしてもまた、プラグインがおかしいと怒られるので、一度Flushします。
mysql> FLUSH PRIVILEGES;
mysql> set password for 'username'@'192.168.128.1' = password('pass');
mysql> exit;

$ mysql -u {ユーザ名} -p
mysql>

これではいれました。

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