#!/usr/bin/env bash Backup_MySQL() { echo "Starting backup all databases..." echo "If the database is large, the backup time will be longer." /usr/local/mysql/bin/mysqldump --defaults-file=~/.my.cnf --all-databases > /root/mysql_all_backup${Upgrade_Date}.sql if [ $? -eq 0 ]; then echo "MySQL databases backup successfully."; else echo "MySQL databases backup failed,Please backup databases manually!" exit 1 fi lnmp stop mv /usr/local/mysql /usr/local/oldmysql${Upgrade_Date} mv /etc/init.d/mysql /usr/local/oldmysql${Upgrade_Date}/init.d.mysql.bak.${Upgrade_Date} mv /etc/my.cnf /usr/local/oldmysql${Upgrade_Date}/my.cnf.bak.${Upgrade_Date} if [ "${MySQL_Data_Dir}" != "/usr/local/mysql/var" ]; then mv ${MySQL_Data_Dir} ${MySQL_Data_Dir}${Upgrade_Date} fi if echo "${mysql_version}" | grep -Eqi '^5.5.' && echo "${cur_mysql_version}" | grep -Eqi '^5.6.';then sed -i 's/STATS_PERSISTENT=0//g' /root/mysql_all_backup${Upgrade_Date}.sql fi } Upgrade_MySQL51() { Tar_Cd mysql-${mysql_version}.tar.gz mysql-${mysql_version} MySQL_Gcc7_Patch if [ $InstallInnodb = "y" ]; then ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase ${MySQL51MAOpt} else ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-assembler --with-mysqld-ldflags=-all-static --with-charset=utf8 --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile ${MySQL51MAOpt} fi sed -i '/set -ex;/,/done/d' Makefile Make_Install groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql cat > /etc/my.cnf< /etc/ld.so.conf.d/mysql.conf< /etc/my.cnf< /etc/ld.so.conf.d/mysql.conf< /etc/my.cnf< /etc/ld.so.conf.d/mysql.conf< /etc/my.cnf< /etc/ld.so.conf.d/mysql.conf< /etc/my.cnf< /etc/ld.so.conf.d/mysql.conf<