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: