#!/bin/bash
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
echo "开始安装mysql"
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
echo "启动mysql"
systemctl start mysqld.service
mysqlPwd=$(grep "temporary password" /var/log/mysqld.log | awk '{print $11}')
mysql -uroot -p$mysqlPwd --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Changeme123\!'";
mysql -uroot -pChangeme123\! --connect-expired-password -e "grant all on *.* to root@'%' identified by 'Changeme123\!'";
systemctl restart mysqld.service