こちらの記事を参考に進める
まずはrootユーザーに、初期のパスワードでログインする
初期のパスワードは
[root@localhost ~]# cat /var/log/mysqld.log | grep “temporary password”
2018-03-01T10:40:41.991676Z 1 [Note] A temporary password is generated for root@localhost: “初期パスワード”
で出る
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.21
Copyright (c) 2000, 2018, 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>
パスワードは簡単にしたいのでパスワード設定条件のレベルを下げる
まずは現状の条件確認
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.05 sec)
パスワードを変えてくださいとエラーが出た場合はこちらを参考にする
変えてみる
SET GLOBAL validate_password_policy=LOW;
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 | LOW |
| validate_password_special_char_count | 1 |
+————————————–+——-+
7 rows in set (0.05 sec)
policyの部分が変わりましたね
次にパスワードを変えましょう
mysql> set password for root@localhost=password(‘設定したパスワード’);
Query OK, 0 rows affected, 1 warning (0.00 sec)
warningが出てるので見てみる
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1287
Message: ‘SET PASSWORD FOR <user> = PASSWORD(‘<plaintext_password>’)’ is deprecated and will be removed in a future release. Please use SET PASSWORD FOR <user> = ‘<plaintext_password>’ instead
1 row in set (0.00 sec)
SET PASSWORD FOR <user> = ‘<plaintext_password>’
でやってくれと言われたのでやってみる
mysql> set password for root@localhost=’設定したパスワード’;
Query OK, 0 rows affected (0.00 sec)
成功したのでログアウトして再度ログインしてみるとうまくいった
mysql> exit
Bye
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>
以上!
コメント