How to upgrade MySQL 5.5 to 5.7 on Linux

Created:

2016-11-16 13:14:34 UTC

Modified:

2017-04-30 17:59:31 UTC

67

Was this article helpful?


Have more questions?

Submit a request

How to upgrade MySQL 5.5 to 5.7 on Linux

Applicable to:

  • Plesk for Linux

Question

How to upgrade MySQL to version 5.6? How to upgrade MariaDB to version 10?

Answer

It is a purely administrative task. Contact your system administrator.

NOTE: Upgrade can be performed in command line by using the instructions below at your own risk:

For Ubuntu 12.04 and 14.04, Debian 7:

Ubuntu 14.04 is shipped with MySQL 5.5 by default.

  1. Create a full server backup and server snapshot.

  2. Create a backup of /etc/mysql/my.cnf :

    # cp /etc/mysql/my.cnf{,_original}
  3. Add the MySQL APT Repository:

    • Go to the download page for the MySQL APT repository at http://dev.mysql.com/downloads/repo/apt/ .

    • Select and download the release package for your platform:

      # wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
    • Install the downloaded release package:

      # dpkg -i mysql-apt-config_0.6.0-1_all.deb

      During the installation of the package, you will be asked to choose the versions of the MySQL server and other components that you want to install. If you are not sure which version to choose, do not change the default options selected for you. You can also choose none if you do not want a particular component to be installed. After making the choices for all components, choose Apply to finish the configuration and installation of the release package.

    • Update package information from the MySQL APT repository:

      # apt-get update
  4. Upgrade MySQL:

        # apt-get install mysql-server

    Agree when prompted to update /etc/mysql/my.cnf

  5. Make sure that mysql-community-libs-compat package is installed. Install if it is missing.
  6. In Plesk go to Tools & Settings > Server Components and click Refresh

  7. Upgrade MySQL databases:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin psa

More information available in MySQL documentation at http://dev.mysql.com/

For CentOS 6:

  1. Stop MySQL service:

    # service mysqld stop
  2. Back up MySQL databases:

    # mkdir /var/lib/mysqlcopy
    # cp -aR /var/lib/mysql/* /var/lib/mysqlcopy
  3. Disable Atomic repository, if it is enabled:

    # vi /etc/yum.repos.d/atomic.repo
    enabled = 0
  4. Install MySQL-community repository:

    # yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
  5. Disable upgrade to MySQL 5.7, enable upgrade to MySQL 5.6:

    # vi /etc/yum.repos.d/mysql-community.repo
    [mysql56-community]
    enabled=1
    [mysql57-community]
    enabled=0
  6. Install MySQL packages:

    # yum update mysql
  7. Make sure that mysql-community-libs-compat package is installed. Install if it is missing.
  8. Start MySQL service:

    # service mysqld start
  9. Upgrade MySQL databases:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin psa

For CentOS 7:

CentOS 7 basically shipped with MariaDB. MariaDB 10.x version is a drop in replacement for MySQL 5.5/5.6.

1. Backup all databases with the following command:

# mysqldump -uadmin -P3306 -p"`cat /etc/psa/.psa.shadow`"  --all-databases > /tmp/all-database.sql

2. Copy the databases directory in a separate folder like this (for backup porposes also):

# cp -a /var/lib/mysql/ /var/lib/mysql.bak

3. Add MariaDB repository:

# vim /etc/yum.repos.d/MariaDB10.repo
# MariaDB 10.1 CentOS repository list - created 2016-01-18 09:58 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

4. Perform an upgrade with

# yum upgrade mariadb-5.5.52-1.el7.x86_64

5. Restart MariaDB service:

# service mysql restart

Then execute this command to update package version inside Plesk:

# plesk sbin packagemng -sdf

Also, if mysql service is enabled in sysV, disable it to avoid duplicate services start up on system boot:

 # chkconfig mysql off 

For Debian 8

Debian 8 basically shipped with MariaDB. MariaDB 10.x version is a drop in replacement for MySQL 5.5/5.6.

Please backup all existing databases using this KB article KB#213904125 and follow instructions on MariaDB site to update it:

https://mariadb.com/kb/en/mariadb/installing-mariadb-deb-files/

Then execute this command to update package version inside Plesk:

# plesk sbin packagemng -sdf

Additional information

The following KB articles may be useful:

Unable to access Application Vault

Can't connect to local MySQL server throug socket

Have more questions? Submit a request
Please sign in to leave a comment.