首次登录mysql,需要修改原始密码。
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)
查看密码策略,在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)
修改指定密码的验证强度等级
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)
修改指定密码长度
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
标题密码策略修改完成后,修改密码为123456
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql>
关于 Mysql 8.0.19 Homebrew 安装版本密码策略相关参数:
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 #整个密码中至少要包含特殊字符的个数;
※ 指定密码的强度验证等级validate_password.policy 取值:
0/LOW #只验证长度;
1/MEDIUM #验证长度、数字、大小写、特殊字符;
2/STRONG #验证长度、数字、大小写、特殊字符、字典文件;
文章来源地址https://www.toymoban.com/news/detail-554777.html
文章来源:https://www.toymoban.com/news/detail-554777.html
到了这里,关于MySQL 8.0 密码策略修改的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!