0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mysql起動後数日経ってログインしたら失敗した

Posted at

概要

mysqlのインストール&デーモン起動まで行って満足してしまい、10日ほど経って初期パスワードによりログインしようとしたところ、なんと入れない...!
(初期パスワードは/var/log/mysqld.logに吐かれている)

初期パスワードの有効期限が数日で切れるというポリシーも見当たらないし困ったなぁということで、パスワードリセットでなんとか対処しました。
同じような事象に遭遇された方いらっしゃいますでしょうか(というかすぐにパスワード変更をしておくべきでした)。

対処コマンド

mysqldを一旦止めて

$ systemctl stop mysqld

一時的にパスワード無しで全権限に触れるよう下記オプションを設定

$ systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

mysqldを起動し、パスワードを再設定しました

$ systemctl start mysqld
$ mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

なお、設定完了後はmysqld停止→変数"MYSQLD_OPTS"を空にし直す→mysqld起動を行っています

$ systemctl set-environment MYSQLD_OPTS=""

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?