MySQL 5.7.5 – Password Policy

Loading

測試環境 CentOS 7

因為大多是實驗性質,我 MySQL 通常會使用很簡單的密碼,但現在會出現以下的錯誤訊息.

Failed! Error: Your password does not satisfy the current policy requirements
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.43 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

因為 Password Policy 我們沒辦法設定簡單密碼.

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('111111');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

validate_password_policy = LOW

第一種方式就是可以把 Policy 降低.

mysql> SET GLOBAL validate_password_policy = LOW;
Query OK, 0 rows affected (0.00 sec)

雖然已經設定成 Low 但密碼不能像是 111111 之類的.

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('111111');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('12345678');
Query OK, 0 rows affected, 1 warning (0.00 sec)

如要成預設需在 my.cnf 加入參數.

[root@localhost ~]# vi /etc/my.cnf
[mysqld]
validate_password_policy=LOW

啟動服務.

[root@localhost ~]# systemctl start mysqld

UNINSTALL PLUGIN validate_password

另外一種方式就是將 validate_password PLUGIN 移除.

mysql> UNINSTALL PLUGIN validate_password;
Query OK, 0 rows affected (0.00 sec)
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('111111');
Query OK, 0 rows affected, 1 warning (0.00 sec)
沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料