MySQL 8.0 password policy modification

When logging in to mysql for the first time, the original password needs to be changed.

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by "123456";
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by "Demo12345!";
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> select &&basedir
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&&basedir' at line 1
mysql> select @@basedir;
+-----------+
| @@basedir |
+-----------+
| /usr/     |
+-----------+
1 row in set (0.00 sec)


To view the password policy, enter after mysql>:

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.00 sec)

Modify the verification strength level of the specified password


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    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 8     |
| 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)

Modify the specified password length


mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)

After the title password policy is modified, change the password to 123456

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> 

About the parameters related to the password policy of the Mysql 8.0.19 Homebrew installation version:

validate_password.dictionary_file    #指定密码验证的文件路径;
validate_password.length    #固定密码的总长度,默认为8;
validate_password.mixed_case_count    #整个密码中至少要包含大/小写字母的总个数;
validate_password.number_count    #整个密码中至少要包含阿拉伯数字的个数;
validate_password.policy    #指定密码的强度验证等级,默认为 MEDIUM;
validate_password.special_char_count    #整个密码中至少要包含特殊字符的个数;

※ Specifies the strength verification level of the password validate_password.policy Value:

0/LOW         #只验证长度;
1/MEDIUM    #验证长度、数字、大小写、特殊字符;
2/STRONG   #验证长度、数字、大小写、特殊字符、字典文件;

Guess you like

Origin blog.csdn.net/weixin_44048054/article/details/131657430