0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[AWS] EC2にMysqlを入れた後の設定

Posted at

Mysqlを最初に入れた時はrootのパスワードは決まっているようで
$ sudo cat /var/log/mysqld.log | grep 'temporary password'
で確認できます

ターミナル
[ec2-user@ip-10-0-1-255 ~]$ sudo cat /var/log/mysqld.log | grep 'temporary password'
2020-02-22T07:34:12.667336Z 1 [Note] A temporary password is generated for root@localhost: F+aB(=GYo2jh

初期のパスワードは F+aB(=GYo2jh らしいです

rootユーザーのパスワードの変更

ターミナル

# とりあえずのパスワードを設定、あとで変更します
mysql> set password for root@localhost=password('passwordPASSWORD@666');
Query OK, 0 rows affected, 1 warning (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             | 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)

#文字数制限変更
mysql> SET GLOBAL validate_password_length=4;
Query OK, 0 rows affected (0.00 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             | 4     |
| 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.00 sec)

# 新しくパスワードを再設定
mysql> set password for root@localhost=password('666666');
Query OK, 0 rows affected, 1 warning (0.00 sec)
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?