下載地址:http://dev.mysql.com/downloads/repo/yum/mysql
下載後,執行以下命令:sql
shell> sudo rpm -Uvh mysql80-community-release-el6-n.noarch.rpm
shell> sudo yum install mysql-community-server
啓動mysqlshell
shell> sudo systemctl start mysqld.service
查看mysql狀態ui
shell> sudo systemctl status mysqld.service
shell> sudo grep 'temporary password' /var/log/mysqld.log
登錄,從新設置密碼spa
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
若是報錯,密碼不符合當前設置的強度規則插件
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
執行以下命令,查看密碼規則code
mysql> 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)
參數解釋:orm
validate_password_dictionary_fileserver
插件用於驗證密碼強度的字典文件路徑。blog
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,因此剛開始設置的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字符。
validate_password_special_char_count 密碼至少要包含的特殊字符數。