MySQL 初始密码问题。
- 第一次执行 sql,MySQL 会提示要修改密码。
[geek@192 tools_my]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.31
Copyright (c) 2000, 2020, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password('root');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
-
但是设置密码又会提示密码不符合策略要求(就是说 MySQL Server 对密码有复杂度要求)。
-
先修改密码要求 。
set global validate_password_policy = 0;
mysql> set global validate_password_length = 4;
Query OK, 0 rows affected (0.00 sec)
- 现在就可以修改密码了。
mysql> set password = password(‘root’);
Query OK, 0 rows affected, 1 warning (0.01 sec)
- 并且可以正常操作了。
mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
±-------------------+
4 rows in set (0.01 sec)