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>