---恢復內容開始---
在MySQL5.6.6之后,ORACLE更新了mysql密碼強度必須要使用大小寫數字符號來設置密碼,但是有時候這樣還是很不方便的.所以記錄一篇如何修改mysql密碼強度的博文.
安裝mysql之后啟動服務,第一次登錄在日志中去找到臨時密碼
[root@localhost ~]# grep "password" /var/log/mysqld.log
2019-10-08T11:02:46.164080Z 1 [Note] A temporary password is generated for root@localhost: YDCvJr;ly3Oq
使用臨時密碼進行登錄
mysql -uroot -pYDCvJr;ly3Oq
登錄后需要先修改密碼才能進行其他操作.
使用ALTER USER username@hostname IDENTIFIED BY "new password"; 修改密碼
ALTER USER root@localhost IDENTIFIED BY "Lai4451231." ;
修改完畢后刷新特權.
FLUSH PRIVILEGES;
然后就可以進行修改密碼策略了,先查看密碼策略.
SHOW VARIABLES LIKE "%password%";
修改密碼策略,修改密碼總長度,我這邊改成5,為了安全建議8位左右
SET GLOBAL validate_password_length=5;
修改密碼強度策略,我這邊改成低策略就不需要大小寫數字和符號了
SET GLOBAL validate_password_policy=0;
這里是臨時生效,要寫入到/etc/my.conf里面才能永久生效,查看一下當前修改后的密碼策略
SHOW VARIABLES LIKE "%password%";
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| default_password_lifetime | 0 |
| disconnect_on_expired_password | ON |
| log_builtin_as_identified_by_password | OFF |
| mysql_native_password_proxy_users | OFF |
| old_passwords | 0 |
| report_password | |
| sha256_password_proxy_users | OFF |
| 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 |
+---------------------------------------+-------+
14 rows in set (0.00 sec)
寫入到/etc/my.conf中[mysqld]下
validate_password_policy=0
validate_password_length=5
重啟服務即可.
systemctl restart mysqld
---恢復內容結束---
