#! /bin/bash
#####################ECS Type Deploy###############
#mail:ratelcloud@foxmail.com
#system:centos7.x
#integration: RatelBoot-EvInit
#####################aliyun yum source
echo "###############Init Yum Source Start....."
mv   /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
echo "###############Init Yum Source End....."

#####################MySQL80Server
echo "###############Install MySQL80 Start....."
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
yum install -y mysql-community-server
yum install -y mysql-community-server --nogpgcheck
echo ">>>>>>install success"
systemctl start  mysqld
systemctl enable mysqld
systemctl status mysqld
grep 'temporary password' /var/log/mysqld.log
TEMP_PWD=$(grep 'temporary password' /var/log/mysqld.log)
PWD=${TEMP_PWD##* }
echo ">>>>>>mysql80 default password:${PWD}"
mysql -uroot -p${PWD}
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zw9vaI@FjdsS4a#%u2AzkTrhp4';
exit
mysql -uroot -p'Zw9vaI@FjdsS4a#%u2AzkTrhp4'
echo ">>>>>>mysql login success..."
# use mysql;
# source /home/init.sql;
exit
echo "##############Install MySQL80 End....."

###################ECS Type Deploy##############