Mysql5.7 パスワードを脆弱なものにする

だって、面倒なんですもの。

# mysql -u root -p
Enter password:   
★セキュリティ用のscriptを動かしていなければ/var/log/mysql.logから引っ張ってこれます。
★ $ cat /var/log/mysqld.log | grep "temporary password"
★忘れたときは....別記事に書いておくのでそちらを参照してください。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18 MySQL Community Server (GPL)

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> show VARIABLES like 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| 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.19 sec)

mysql> set global validate_password_length=5;
Query OK, 0 rows affected (0.03 sec)

mysql> set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)

mysql> show VARIABLES like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 5 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)

mysql> set password for root@localhost=password('ichgo');
Query OK, 0 rows affected, 1 warning (0.12 sec)

mysql> flush privileges;


 

mysql> show VARIABLES like 'validate_password%'; 
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

と怒られたときは先にrootのパスワードを複雑なものに設定しておくと良いです。直後に設定してしまうので忘れそうなモノでも構いません。大文字小文字数字記号を含めた8文字以上。

mysql> set password for root@localhost=password('IchiGo100%');
mysql> show VARIABLES like 'validate_password%';
(ommitted)
7 rows in set (0.01 sec)

以下この記事の先頭から~