一、一键安装Mysql脚本

[root@uat01 ~]# cat InstallMysql01.sh
#!/bin/bash
#--
#旅行者-Travel
#.安装wget
yum -y install wget
#、下载mysql的yum源
URL="https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm"
wget $URL -P /etc/yum.repos.d/
yum -y install yum-utils #如果没有该包,下边执行yum-config-manager不生效
yum -y install /etc/yum.repos.d/mysql80-community-release-el7-.noarch.rpm
if [ $? -eq ];then
rm -rf /etc/yum.repos.d/mysql80-community-release-el7-.noarch*
fi
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum -y install mysql-community-server
sleep
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
if [ $? -eq ];then
echo -e "install succefull"
result="`grep 'temporary password' /var/log/mysqld.log`"
p1="`echo $result |awk '{print $NF}'`"
echo "数据库密码为:$p1" fi
[root@uat01 ~]#

二、修改策略和密码

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

install succefull
数据库密码为:9aTR&ok>f;1K
[root@uat01 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. Copyright (c) , , 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> set global validate_password_policy=;
Query OK, rows affected (0.00 sec) mysql> set global validate_password_length=;
Query OK, rows affected (0.00 sec) mysql> alter user 'root'@'localhost' identified by 'Yanglt123.';
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.00 sec) mysql> quit

三、数据库密码策略:

1、查看数据库策略:

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

[root@uat01 ~]# mysql -uroot -p
.....
Server version: 5.7. MySQL Community
......
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | |
| validate_password_mixed_case_count | |
| validate_password_number_count | |
| validate_password_policy | LOW |
| validate_password_special_char_count | |
+--------------------------------------+-------+
rows in set (0.00 sec) 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=;
Query OK, rows affected (0.00 sec)
mysql> set global validate_password_length=;
Query OK, rows affected (0.00 sec),
mysql> flush privileges;
Query OK, rows affected (0.00 sec)

4、修改简单密码测试

mysql> alter user 'root'@'localhost' identified by ''; #测试发现密码长度最少为4位
Query OK, rows affected (0.00 sec) mysql> flush privileges;
Query OK, rows affected (0.01 sec) mysql> quit
Bye
[root@uat01 ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7. MySQL Community Server (GPL) Copyright (c) , , 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>

【shell 每日一练7】一键安装mysql5.7,以及密码及策略修改的更多相关文章

  1. shell脚本一键安装mysql5.7.x

    使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...

  2. shell脚本一键安装mysql5.7.x(免安装版)

    使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...

  3. 【shell 每日一练6】初始化安装Mysql并修改密码

    一.简单实现mysql一键安装 参考:[第二章]MySQL数据库基于Centos7.3-部署 此脚本前提条件是防火墙,selinux都已经设置完毕: [root@web130 ~]# cat Inst ...

  4. 一键安装MySQL5.6.43脚本

    [root@lamp ~]# cat /server/scripts/mysql-5.6.43_install.sh #!/bin/bash #卸载系统自带的Mysql /bin/rpm -e $(/ ...

  5. mysql5.7忘记密码时,修改root密码

    (1).由于MySQL5.7在安装完后,第一次启动时,会在root目录下生产一个随机的密码,文件名为 .mysql_secret 所以,登录时需要用随机密码登录,然后通过以下命令修改密码 “SET P ...

  6. 《oracle每日一练》免安装Oracle客户端使用PL/SQL

    免安装Oracle客户端使用PL/SQL Oracle客户端挺招人烦的,部署连接它的应用通常需要先安装它的客户端,安装程序要求在目标机器上写注册表,假设你没有洁癖的话,你仍可能被下面的事情绊住:当你的 ...

  7. CentOS6.5一键安装MySQL5.5.32(源码编译)

    ###################################################mysql_install.sh                                 ...

  8. 一键安装mysql5.6

    #!/bin/bash # @Name:install_mysql.sh # @Author:Eivllom # @Create -- # @Modify -- app_soft="/app ...

  9. mysql5.7安装部署后初始密码查看以及修改

    一.查看初始密码以下两种方法: 1.找到自己的error.log日志文件,执行自己的命令,红色标记的部分为初始化密码. grep 'temporary password' /data/mysql/er ...

随机推荐

  1. sharepoint OOS打开文档使用新窗口

    总体说来就是在<a>标签上嵌入_blank $("a[onclick*='return DispEx'][target!='_blank']") .attr(" ...

  2. GoBelieve IM 消息推送的方案

    消息推送设计方案如下: 所有接入im SDK的deviceTOken都会存储到IM服务器.就可以 IM服务器来根据你们服务器指定的useId来下发消息.判断客户端在线,并且APP在前台.就是socke ...

  3. iOS利用block实现链式编程方法(Objective-C链式编程)

    objc利用block实现链式编程方法 因为不好读.block和其他语言的匿名函数一样,很多程序员刚开始很难主动去用他. 本文描述block作为属性的实际使用,看懂block,并讲解如何利用block ...

  4. SVN搭建(linux 7)

    第一步:通过yum命令安装svnserve,命令如下: >yum -y install subversion 此命令会全自动安装svn服务器相关服务和依赖,安装完成会自动停止命令运行 若需查看s ...

  5. #leetcode刷题之路31-下一个排列

    实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列.如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列).必须原地修改,只允许使用额外常数空间. 以下 ...

  6. Mysql-数据的完整性约束

    一 .介绍 二 .not null与default 三 .unique 四 .primary key 五 .auto_increment 六 .foreign key 一 .介绍 约束条件与数据类型的 ...

  7. HCNA(一)网络传输介质

    一 .同轴线缆 介绍:同轴线缆是一种早期的网络传输介质,同轴电缆的得名与它的结构相关,由内导体.外导体.绝缘介质和防护套四部分组成.同样支持10Mbps传输速率.现在已经基本被淘汰,不在应用于企业网络 ...

  8. IOTutility 一个轻量级的 IOT 基础操作库

    IOTutility 一个轻量级的 IOT 基础操作库 Base utility for IOT devices, networking, controls etc... IOTutility 的目的 ...

  9. 20155203 2016-2017-2 《Java程序设计》第1周学习总结

    20155203 2016-2017-2 <Java程序设计>第1周学习总结 学习目标 - 了解Java基础知识[第一章] Java是各应用平台的基础,Java分为三大平台:Java三大平 ...

  10. # 学号20155308 2006-2007-2 《Java程序设计》第4周学习总结

    学号20155308 2006-2007-2 <Java程序设计>第4周学习总结 教材学习内容总结 6.1 何谓继承 继承基本上就是避免多个类间重复定义共同行为. 许多类之间具有相同的属性 ...