LoginSignup
0
0

[Mac] MySQLの初期化でセキュリティレベルをMEDIUMにしたらハマった

Posted at

環境

  • MacOS
  • MySQL v8.0.32

前提

  • homebrewをインストール済みであること

MySQLインストール

brew install mysql
# MySQL初期化
mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
                                            #  VALIDATE PASSWORD プラグイン の利用確認
Press y|Y for Yes, any other key for No: y ← 「y」を押下

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

# セキュリティレベルの設定。ここで 1 を押下してしまった
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:

上記手順により、MySQLのパスワードを8文字以上、数字、大/小文字混合、および特殊文字に設定しないと行けなくなった。

ハマった

セキュリティレベルの次に進むとrootパスワードの設定が求められ、入力条件を満たさないとエラーで弾かれてしまう。(ただローカルで開発したいだけなのに)

Please set the password for root here.

MySQLを再インストールし、mysql_secure_installation(初期化)を再実行しても、一度設定したセキュリティレベルを再設定することはできなかった。

解決策

MySQLのテーブル設定からセキュリティレベルを変更する

以下手順

  • MySQLを立ち上げ、ログインする
mysql.server start
mysql -u root
  • パスワード関連のテーブルを確認する
SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
  • セキュリティレベルを緩くする
set global validate_password.policy=LOW;
set global validate_password.check_user_name=OFF;
set global validate_password.length=6;
commit;

quitで抜け、再度mysql_secure_installationを実行すると、セキュリティレベルが緩くなっているので適当に6文字以上のパスワードを入力すると次に進めるようになる。

終わりに

  • ローカルで開発したいだけならセキュリティレベルはLOWにしておくのがオススメ
  • Windowsだとインストーラー時点で設定するので無縁
0
0
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
0