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で「You must reset your password」エラーが出たので、自分の環境で解決してみた

Last updated at Posted at 2025-04-02

はじめに

MySQLの初期セットアップ時、rootユーザーのパスワードが期限切れ状態で設定されていることがあり、操作が制限されるケースがあります。この記事では、そのエラーの内容と対処法を簡潔にまとめます。

書こうと思ったきっかけ

新しいMySQL環境で show databases; を実行した際、パスワードの変更を促すエラーに遭遇しました。初めて見ると戸惑うエラーなので、今後のために対応手順を残しておこうと思いました。

エラーの内容

MySQL初期設定後、以下のようなエラーが表示される場合があります:

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

解決方法:ALTER USERでパスワードを変更

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass123!';

その後、ログアウトして再度ログインすることで、通常どおりMySQLを利用できるようになります。

まとめ

このエラーは、MySQLのセキュリティ機能により初期パスワード変更が強制される仕様です。慌てず ALTER USER を使ってパスワードを再設定すれば解決できます。開発や検証環境であっても、パスワードの管理はしっかり行うよう心がけましょう。

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?