在 CentOS 1804 中 修改 MySQL 密碼策略
相關連結:
在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版
在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本)
在不開啟 MySQL 3306 埠的情況下,使用 Navicat 進項遠端連線(使用22埠)
在 Ubuntu 中安裝 MySQL5.7.20(任意版本)
CentOS 6/7 安裝 MySQL 8.0.11 (或任意版)
- 登入MySQL,檢視當前策略:
[[email protected] doc]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.7.20 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.00 sec)
-
validate_password_check_user_name
使用者名稱檢測 -
validate_password_dictionary_file
外掛用於驗證密碼強度的字典檔案路徑。 -
validate_password_length
密碼最小長度,引數預設為8,它有最小值的限制,最小值為:
validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count) -
validate_password_mixed_case_count
密碼至少要包含的小寫字母個數和大寫字母個數。 -
validate_password_number_count
密碼至少要包含的數字個數。 -
validate_password_policy
密碼強度檢查等級,0/LOW、1/MEDIUM、2/STRONG。有以下取值:
Policy Tests Performed
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
預設是1,即MEDIUM,所以剛開始設定的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字元。
-
- 修改密碼策略:
mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_mixed_case_count=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_number_count=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_special_char_count=0; Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=4; 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 | 0 | | validate_password_number_count | 0 | | validate_password_policy | LOW | | validate_password_special_char_count | 0 | +--------------------------------------+-------+ 7 rows in set (0.01 sec)
- 將root使用者本地連線密碼修改為root:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); Query OK, 0 rows affected, 1 warning (0.01 sec)
- 將root使用者遠端連線密碼修改為root:
遠端連線需要開啟3306埠,請檢視文章開始或結束處的相關文章。mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root'; Query OK, 0 rows affected, 1 warning (0.00 sec)
相關連結:
在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版
在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本)
在不開啟 MySQL 3306 埠的情況下,使用 Navicat 進項遠端連線(使用22埠)
在 Ubuntu 中安裝 MySQL5.7.20(任意版本)
CentOS 6/7 安裝 MySQL 8.0.11 (或任意版)