> \#!/bin/bash
> DIR=`pwd`
> NAME="mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz"
> FULL_NAME=${DIR}/${NAME}
> DATA_DIR="/data/mysql"
>
> yum install -y libaio perl-Data-Dumper
>
> if [ -f ${FULL_NAME} ];then
> echo "安装文件存在"
> else
> echo "安装文件不存在"
> exit 3
> fi
> if [ -h /usr/local/mysql ];then
> ? echo "Mysql 已经安装"
> ? exit 3
> else
> tar xvf ${FULL_NAME} -C /usr/local/src
> ln -sv /usr/local/src/mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql
> if id mysql;then
> ? echo "mysql 用户已经存在,跳过创建用户过程"
> else
> ? useradd -r -s /sbin/nologin mysql
> ? fi
> if id mysql;then
> ? chown -R mysql.mysql /usr/local/mysql/*
> ? if [ ! -d /data/mysql ];then
> ? mkdir -pv /data/mysql && chown -R mysql.mysql /data -R
> ? /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql/
> ? cp /usr/local/src/mysql-5.6.47-linux-glibc2.12-x86_64/support-files/mysql.server /etc/init.d/mysqld
> ? chmod a+x /etc/init.d/mysqld
> ? \cp ${DIR}/my.cnf /etc/my.cnf
> ? ln -sv /usr/local/mysql/bin/mysql /usr/bin/mysql
> ? /etc/init.d/mysqld start
> ? chkconfig --add mysqld
> else
> ? echo "MySQL数据目录已经存在,"
> exit 3
> ? fi
> fi
> fi
mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz
[mysqld]
socket=/data/mysql.sock
user=mysql
symbolic-links=0
datadir=/data/mysql
innodb_file_per_table=1
[client]
port=3306
socket=/data/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/tmp/mysql.sock
vim install_mysql.sh
原文:https://www.cnblogs.com/askword/p/14855840.html