#!/bin/bash #1.获取当前脚本所在目录 mysql_dir=$(pwd) #2.进入当前脚本目录 cd $mysql_dir #3.下载文件 wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm #4.YUM repository yum -y install mysql57-community-release-el7-10.noarch.rpm #5.在线安装mysql rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 sleep 5 yum -y install mysql-community-server #5.配置 cmake -DCMAKE_INSTALL_PREFIX=$mysql_dir/mysql -DMYSQL_DATADIR=$msyql_dir/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci #6.卸载Yum Repository yum -y remove mysql57-community-release-el7-10.noarch #7.输出信息 systemctl start mysqld.service echo "mysql完成安装" #8.检测是否成功 mysql_status=$(systemctl status mysqld) status="running" result=$(echo $mysql_status |grep "${status}") if [["result" != "" ]]; then echo "mysql安装成功" else echo "mysql安装失败,检查原因" fi
centos7一键安装mysql5.7,返回是否安装成功
于 2022-11-04 11:47:29 首次发布