1. 登录mysql
➜ ~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 8.0.12 Homebrew
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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.
mysql>
2. 修改mysql密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
此时报错 重新设置的密码不符合当前策略
安装mysql的时候选择的low
默认是8位密码,现在想设置为6位报错
3. 查看策略
SHOW VARIABLES LIKE 'validate_password%';
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.02 sec)
4. 设置密码
// 设置策略
set global validate_password.policy=LOW;
// 设置密码长度
set global validate_password.length=6;
// 设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
// 设置策略
mysql> set global validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)
// 设置密码长度
mysql> set global validate_password.length=6;
Query OK, 0 rows affected (0.00 sec)
// 设置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.08 sec)
mysql>
网友评论