一键安装mysql5.7及密码策略修改方法
作者:旅行者-Travel 发布时间:2024-01-22 05:29:37
标签:安装,mysql5.7,密码
一、一键安装Mysql脚本
[root@uat01 ~]# cat InstallMysql01.sh
#!/bin/bash
#2018-10-13
#旅行者-Travel
#1.安装wget
yum -y install wget
#2、下载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-1.noarch.rpm
if [ $? -eq 0 ];then
rm -rf /etc/yum.repos.d/mysql80-community-release-el7-1.noarch*
fi
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
yum -y install mysql-community-server
sleep 5
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
if [ $? -eq 0 ];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 2
Server version: 5.7.23
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> 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
[root@uat01 ~]# mysql -uroot -p
.....
Server version: 5.7.23 MySQL Community
......
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| 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)
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)
mysql> quit
Bye
[root@uat01 ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.23 MySQL Community Server (GPL)
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>
总结
以上所述是小编给大家介绍的一键安装mysql5.7及密码策略修改方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家大家的!
来源:https://www.cnblogs.com/yangleitao/archive/2018/10/13/9784726.html


猜你喜欢
- xorm用于在golang中链接数据库,并完成增删改差操作,不管是orm还是raw方式都十分的新颖简单。sql语句postgresql pg
- 今天分享的这篇文章,文字不多,代码为主。绝对干货,童叟无欺,主要分享了提升 Python 性能的 20 个技巧,教你如何告别慢Python。
- 复制数据库前要先确认目标数据库的服务是否启动主要是SQL Server (MSSQLSERVER)这个服务要启动起来其他的看自己的需求复制数
- 以下为测试例子。 1.首先创建两张临时表并录入测试数据: 代码如下:create table #temptest1 ( id i
- 网上关于PyQt5的教程很少,特别是界面跳转这一块儿,自己研究了半天,下来和大家分享一下一、首先是主界面# -*- coding: utf-
- 1. 项目背景视频传输: 在一台电脑上播放视频(捕捉摄像头画面),同局域网内另一台电脑上实时播放,尽量不卡顿。先放最后的照片,和用gif展示
- Anaconda3-5.1.0-MacOSX-x86_64.pkg 下载安装后,附带安装了pytorch包。需要将环境调整到新的python
- 在曾经的 淘宝UED 招聘 中有这样一道题目:“使用纯CSS实现未知尺寸的图片(但高宽都小于200px)在200px的正方形容器中水平和垂直
- 现有1.php内容如下: <?phpecho 'hi\nhi';在命令行中执行该文件: bash >> p
- 1、Python数据存储(压缩)(1)numpy.save , numpy.savez , scipy.io.savematnumpy和sc
- 企业最有价值的资产通常是其数据库中的客户或产品信息。因此,在这些企业中,数据库管理的一个重要部分就是保护这些数据免受外部攻击,及修复软/硬件
- z-blog摘要图文混排,在月光的博客早已有介绍,但是他的图文混排是基于一篇文章只定义一个Tag的情况,对于我这样习惯多tag的博客,再更改
- 前言:终于来了一篇有质量的文章,我个人感觉非常不错,《jfinal与bootstrap之间的登录跳转实战》。具体内容包含有点击登录弹出模态框
- 文件拆分代码:#-*-encoding:utf-8-*-import osimport sysimport threadingdef get
- 我设了两个SESSION:SESSION(A1),SESSION(A2),然后我现在想结束其中一个SESSION(如:ESEEION(A1)
- 本文实例为大家分享了python实现抠图给证件照换背景的具体代码,供大家参考,具体内容如下import cv2import numpy as
- 函数较简单,看下面的例子: s = 'hEllo pYthon' print s.upper() print s.lower
- 在之前的工作中,业务方做了一些调整,提出了对一部分核心指标做更细致的拆分并定期产出的需求。出于某些原因,这部分数据不太方便在报表上呈现,因此
- jQuery 操作 CSSaddClass() - 向被选元素添加一个或多个类removeClass() - 从被选元素删除一个或多个类to
- 开发环境:python版本2.X#!/usr/bin/env python# -*- coding:utf-8 -*-# 适合python版