#! /bin/sh . /usr/src/m2/framework/bash_functions.sh _centos_version if (( centos_version != 6 )); then report "Your system is Centos $centos_version, this script is for Centos 6, aborting..." 1 exit else report "Centos 6 detected" 0 fi mysql_server_version if [[ $MYSQL_VERSION == *"5.5"* ]]; then report "MySQL version $MYSQL_VERSION detected" 0 else report "This script is for MySQL version 5.5.x, your MySQL version is $MYSQL_VERSION, aborting..." 1 exit fi # 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 exit; fi # based on https://www.basvanbeek.nl/linux/upgrade-mysql-5-5-to-5-7-on-centos-6/ yum update -y yum yum install -y yum-utils yum -y remove php-mysql php-common #remi crap dependencies service mysqld stop cd /usr/src/ wget https://dev.mysql.com/get/mysql80-community-release-el6-2.noarch.rpm sudo rpm -Uvh mysql80-community-release-el6-2.noarch.rpm sudo yum-config-manager --enable mysql57-community sudo yum-config-manager --disable mysql80-community yum -y update mysql #change /etc/my.cnf variables cp -fr /etc/my.cnf /etc/my.cnf_backup_upgrade55_57 sed -i -e 's/table_cache/table_open_cache/g' /etc/my.cnf 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 service mysqld start mysql_upgrade -u root -pkolmisoft service mysqld restart mysql_connect_data_v2 mysql_upgrade --force -h "$DB_HOST" -u $DB_USERNAME --password=$DB_PASSWORD # new php version for phpmyadmin yum install -y php-cli php-common php-mbstring php-mysql php-mbstring php-mcrypt mod_php service httpd install mysql_server_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