#! /bin/sh . /usr/src/k_framework/main.sh SCRIPT_NAME="MySQL 5.6 to 5.7 upgrade" VERSION="1.0.4" k_start k_config_details k_centos_version if (( centos_version != 7 )); then report "Your system is Centos $centos_version, this script is for Centos 7, aborting..." 1 k_exit 1 fi k_mysql_version if [[ $MYSQL_VERSION != *"5.6"* ]]; then report "This script is for MySQL version 5.6.x, your MySQL version is $MYSQL_VERSION, aborting..." 1 k_exit 1 else report "MySQL version $MYSQL_VERSION detected" 0 fi report "REPLICATION WILL BE LOST, YOU WILL NEED TO REBUILD IT!!!" 2 # make db backup! echo read -p "Do you have a DB backup? (YES I HAVE/n)?" CONT if [ "$CONT" = "YES I HAVE" ]; then report "Script will proceed with the MySQL upgrade from $MYSQL_VERSION(remi) to 5.7 on Centos 6" 0 else report "C'mon man... Go make a database backup, this is dangerous stuff..." 1 report " mysqldump --single-transaction -u $SYSTEM_CONFIG_DIR -p$SYSTEM_CONFIG_DIR $SYSTEM_CONFIG_DIR | gzip -9 > /tmp/db_backup.sql.gz" fix k_exit 1 fi # based on https://plenium.medium.com/upgrade-mysql-5-6-to-5-7-on-centos-7-571652f0cbc8 wget http://repo.mysql.com/mysql57-community-release-el7.rpm -P /usr/src yum remove -y mysql-community-release rpm -ivh /usr/src/mysql57-community-release-el7.rpm yum-config-manager --disable mysql80-community yum-config-manager --disable mysql56-community yum-config-manager --enable mysql57-community k_service_stop mysqld rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 yum update -y mysql report "my.cnf backup moved to /etc/my.cnf_backup_upgrade56_57" 3 mv /etc/my.cnf /etc/my.cnf_backup_upgrade56_57 cp -fr /usr/src/k_framework/helpers/mysql/5.7/my.cnf /etc/ #sed -i -e 's/key_buffer/key_buffer_size/g' /etc/my.cnf #sed -i -e 's/thread_concurrency/innodb_thread_concurrency/g' /etc/my.cnf #sed -i -e 's/table_cache/table_open_cache/g' /etc/my.cnf k_service_start mysqld mysql_upgrade -u root -pkolmisoft --force k_service_restart mysqld systemctl status mysqld k_mysql_version if [[ $MYSQL_VERSION == *"5.7"* ]]; then report "MySQL upgraded to version $MYSQL_VERSION" 0 else report "MySQL upgrade to version 5.7 failed... Check the logs, fix the script." 1 fi /usr/src/k_framework/helpers/mysql/mysql_check.sh k_exit $EXIT_CODE