#!/bin/bash
#更改主机名
hostnamectl set-hostname mysql
a=`ss -nulpt | grep 3306 | awk -F: '/tcp/{print $4}'`
if [ ${a} == 3306 ];then
echo "install mysql"
echo "ok"
else
echo "no install mysql"
#创件yum仓库
echo -e "[mysql57-community]\nname=MySQL 5.7 Community Server\nbaseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/local.repo
yum clean all && yum makecache &> /dev/null
#装包
yum install -y httpd php php-mysqlnd php-xml php-json mysql-community* &> /dev/null
systemctl enable mysqld --now
b=`ss -nulpt | grep 3306 | awk -F: '/tcp/{print $4}'`
if [ ${b} == 3306 ];then
echo "install mysql"
if [ $? == 0 ];then
echo "ok"
mysqladmin -uroot -p`grep -i password /var/log/mysqld.log | awk 'NR==1{print $11}'` password NSD2021@tedu.cn
echo "passwd is ok"
else
echo "no"
fi
fi
fi
|