【shell 每日一练7】一键安装mysql5.7,以及密码及策略修改
一、一键安装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,以及密码及策略修改的更多相关文章
- shell脚本一键安装mysql5.7.x
使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...
- shell脚本一键安装mysql5.7.x(免安装版)
使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...
- 【shell 每日一练6】初始化安装Mysql并修改密码
一.简单实现mysql一键安装 参考:[第二章]MySQL数据库基于Centos7.3-部署 此脚本前提条件是防火墙,selinux都已经设置完毕: [root@web130 ~]# cat Inst ...
- 一键安装MySQL5.6.43脚本
[root@lamp ~]# cat /server/scripts/mysql-5.6.43_install.sh #!/bin/bash #卸载系统自带的Mysql /bin/rpm -e $(/ ...
- mysql5.7忘记密码时,修改root密码
(1).由于MySQL5.7在安装完后,第一次启动时,会在root目录下生产一个随机的密码,文件名为 .mysql_secret 所以,登录时需要用随机密码登录,然后通过以下命令修改密码 “SET P ...
- 《oracle每日一练》免安装Oracle客户端使用PL/SQL
免安装Oracle客户端使用PL/SQL Oracle客户端挺招人烦的,部署连接它的应用通常需要先安装它的客户端,安装程序要求在目标机器上写注册表,假设你没有洁癖的话,你仍可能被下面的事情绊住:当你的 ...
- CentOS6.5一键安装MySQL5.5.32(源码编译)
###################################################mysql_install.sh ...
- 一键安装mysql5.6
#!/bin/bash # @Name:install_mysql.sh # @Author:Eivllom # @Create -- # @Modify -- app_soft="/app ...
- mysql5.7安装部署后初始密码查看以及修改
一.查看初始密码以下两种方法: 1.找到自己的error.log日志文件,执行自己的命令,红色标记的部分为初始化密码. grep 'temporary password' /data/mysql/er ...
随机推荐
- 【Step By Step】将Dotnet Core部署到Docker上
本教程的前提是,你已经在Linux服务器上已经成功的安装了Docker,我会大概介绍在此过程中用到的Docker命令,并不会介绍所有的Docker命令(因为我也不会). 一.在Docker中运行Dot ...
- Web—09-正则表达式
正则表达式 1.什么是正则表达式: 能让计算机读懂的字符串匹配规则. 2.正则表达式的写法: var re=new RegExp('规则', '可选参数'); var re=/规则/参数; 3.规则中 ...
- Oracle数据库对表基本的操作--增删查改
--向student表中加入入学时间属性,其数据类型为日期型alter table student add scome date; --删除student表中的入学时间属性alter table st ...
- plsql developer 64位 注册码
注册码product code(产品编码): 4vkjwhfeh3ufnqnmpr9brvcuyujrx3n3le serial Number(序列号):226959 password(口令): xs ...
- c#将List转换成DataTable
前面写了一篇List<T>转换成DataTable,这里主要是完善了前面的代码. 同样使用了emit,我把代码整理后上传了git. 另外增加了特性的设计. 设计了三类特性ColumnTyp ...
- SQL循环插入批量数据
declare @i intdeclare @qid int set @i=1set @qid=100 while @i<50000begininsert into Order(orderid, ...
- LR分析-demo2
0.LR分析 用一个栈来保存文法符号和状态的信息,一个字符串保存输入信息. 使用栈顶的状态符号和当前的输入符号来检索分析表,来决定移进-归约分析的动作. 1.样例文法 "E>E+T&q ...
- echarts中跨域动态获取数据时,当某些对应的数据为空时,鼠标滑动到所在位置卡死
才疏学浅,万望指点. formatter: function (params) { var rel = params[0].name + "<br />"; rel + ...
- django中对数据库的增删改查
Django的配置文件时settings.py中的 TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplate ...
- vue-cli 3.0 豆瓣api接口使用element做分页
记录自己的学习 大佬绕道谢谢! 豆瓣即将上映接口:https://api.douban.com/v2/movie/coming_soon 本地跨域问题 看我之前的文章:https://www.cnbl ...