一键安装MySQL 5.7与密码及策略修改

一、一键安装MySQL脚本

二、修改策略和密码

执行完以上脚本可以看到MySQL的密码,如下方法登录修改策略,因为默认密码要求比较高,可以根据自己需求来决定是否更改策略:

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> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)

mysql>  alter user 'root'@'localhost' identified by 'Yanglt123.';
Query OK, 0 rows affected (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

三、数据库密码策略:

1、查看数据库策略:

因为上文已经将 validate_password_length 值改为4,所以下文显示为4,默认情况下为8

mysql>

2、各项值说明

validate_password_policy:密码安全策略,默认MEDIUM策略

策略 检查规则
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

   

validate_password_dictionary_file:密码策略文件,策略为STRONG才需要

validate_password_length:密码最少长度 ,测试发现最小值得为4。

validate_password_mixed_case_count:大小写字符长度,至少1个

validate_password_number_count :数字至少1个

validate_password_special_char_count:特殊字符至少1个

3、修改策略,跟上文第二操作一样

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec),
mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

4、修改简单密码测试

mysql> alter user 'root'@'localhost' identified by '1234'; #测试发现密码长度最少为4位
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

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>

猜你喜欢

转载自www.linuxidc.com/Linux/2018-10/154810.htm
今日推荐