ps:本文采用5.7.24-ce版本,软件可以云清华源下载,上传到:/data/soft
#!/bin/bash
###1.初始化环境
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g’ /etc/sysconfig/selinux
setenforce 0
###2.定义变量
hostnamectl set-hostname master
ip=$(ifconfig | awk 'NR==2{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲') Hostname=(hostname)
3.mysql初始化
####3.1安装包路径,上传安装包
mkdir -p /data/soft && mkdir /application
yum install -y lrzsz
####3.2解压软件到配置文件路径
cd /data/soft
tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql
####3.3设置环境变量
echo export PATH=/application/mysql/bin/:$PATH >>/etc/profile
source /etc/profile &