shell脚本部署mysql
文章目录
准备工作
下载mysql的软件包
[root@localhost ~]# cd /opt/
[root@localhost opt]# ls
data mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
编写脚本
[root@localhost ~]# vi yhm.sh
[root@localhost ~]# cat yhm.sh
#!/bin/bash
#关闭防火墙和selinux
echo "正在关闭防火墙和selinux"
systemctl stop firewalld
systemctl disable firewalld &> /dev/null
setenforce 0
#安装yum源
echo "正在安装yum源"
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo &> /dev/null
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm &> /dev/null
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*