#!/bin/bash
echo "安装mysql5.7.30,按任意键继续"
read -n1
mkdir -p /data/software
cd /data/software
curl -O http://down.yadeaiot.net:8000/mysql-community-client-5.7.32-1.el7.x86_64.rpm
curl -O http://down.yadeaiot.net:8000/mysql-community-common-5.7.32-1.el7.x86_64.rpm
curl -O http://down.yadeaiot.net:8000/mysql-community-libs-5.7.32-1.el7.x86_64.rpm
curl -O http://down.yadeaiot.net:8000/mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm
curl -O http://down.yadeaiot.net:8000/mysql-community-server-5.7.32-1.el7.x86_64.rpm
mkdir -p /data/mysql && cd /data/mysql
yum install -y /data/software/mysql-community-*-5.7.32-1.el7.x86_64.rpm
# 开启MySQL服务器 
systemctl start mysqld 
systemctl enable mysqld 
# 查看默认生成的密码 
cat /var/log/mysqld.log | grep password
passwd1=`cat /var/log/mysqld.log | grep password | grep "root@localhost" | awk -F "@" '{print $2}'|awk -F " " '{print $2}'`
mysql -uroot -h127.0.0.1 -p$passwd1 -P3306 --connect-expired-password -e "set global validate_password_length=4;set global validate_password_policy=0;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yadea123';flush privileges;"
echo "mysql安装完成，默认密码为yadea123"
