How to upgrade MySQL 5.5 to 5.6/5.7 on Linux

Created:

2016-11-16 13:14:34 UTC

Modified:

2017-08-21 11:54:13 UTC

143

Was this article helpful?


Have more questions?

Submit a request

How to upgrade MySQL 5.5 to 5.6/5.7 on Linux

Applicable to:

  • Plesk for Linux

Table of contents

Warning: Direct upgrade of MySQL 5.1 to MySQL 5.6/5.7 will damage tables. MariaDB 10.2 is not fully supported by Plesk

Note: Upgrade can be performed in a command line by using the instructions below at your own risk. This task is supposed to be performed by a system administrator.

First of all, connect to the server using SSH or run Terminal.

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

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. Select MySQL version:

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

  6. Install MySQL packages:

    # yum update mysql

    If update of mysql package ends with Nothing to do message, make sure that mysql* packages are not added to excludes in yum.conf file and remove it if it is in the list:

    # cat /etc/yum.conf | grep exclude
    exclude=php-common php-cli php mysql* httpd* mod_ssl*

  7. Type y if this message appears:

    CONFIG_TEXT: warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Importing GPG key 0x5072E1F5:
    Userid : MySQL Release Engineering <mysql-build@oss.oracle.com>
    Package: mysql57-community-release-el6-7.noarch (@/mysql57-community-release-el6-7.noarch)
    From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Is this ok [y/N]:

  8. Start MySQL service:

    # service mysqld start

    If the service does not start, check the following article: MySQL fails to start: mysql.user table is damaged

  9. Upgrade MySQL databases:

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

For CentOS 7:

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

  1. Backup all databases with the following command:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -uadmin --all-databases > /tmp/all-database.sql

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

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

  3. Stop MariaDB service:

    # service mariadb stop

  4. Add MariaDB repository:

    # vi /etc/yum.repos.d/MariaDB10.repo
    # MariaDB 10.1 CentOS repository list - created 2016-01-18 09:58 UTC
    # http://mariadb.org/mariadb/repositories/

    [mariadb10.1]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.1/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    enabled=1

  5. Perform an upgrade with

    # yum install mariadb

  6. Start MariaDB service:

    # service mysql start

  7. Execute this command to update package version inside Plesk:

    # plesk sbin packagemng -sdf

    Note: After upgrade to 10.2 version, there may appear 'mysql' init script. We recommend removing it:

    # rm -f /etc/init.d/mysql
    # systemctl daemon-reload

For Debian 8

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

Please, backup all existing databases using this KB article How to backup/restore a Plesk database dump? and follow instructions on MariaDB site to update it:

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

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

10 Comments

  • 0
    Avatar
    Artur Beqiraj

    i have centos 7 end plesk Onyx end i need to have mariaDB 10.0.27 is possible ?

    Is there any way to get this version?

    thanks

  • 0
    Avatar
    Alexandr Tumanov

    Hello @Artur Beqiraj

    We recommend upgrading to MariaDB 10.1 at least. There is no significant difference, however, it will be easier to install MariaDB 10.1 or 10.2

  • 0
    Avatar
    Artur Beqiraj

    Hello Alexandr and thank you for your reply

    But I have a soft who works only with mysql 5.6 or MariaDB 10.0.27

    For this reason i am using the cpanel
    But I'm not practical with it, Because I've always used plesk on my servers. Your article
    gives you the opportunity to upgrate but if I changed the url to

    baseurl = http://yum.mariadb.org/10.2/centos7-amd64 in /10.0.27/  run into errors 

    for this reason i ask you

    thanks

  • 0
    Avatar
    Peter Jablonski

    It didn't work for me in 100%.

    I was upgrading MySQL 5.1 to 5.7 om my CentOS 6 and I couldn't start mysql.

    # service mysqld start - gave me nothing, even no single line in /var/log/mysqld.log.

     

    What I did:

    1. I started mysql service from a file /usr/sbin/msqld to check what a problem was

    2. The problem was in config file /etc/my.cnf

    [ERROR] unknown variable 'innodb_additional_mem_pool_size=500K'

    I had to comment this line.

    3. After that I had a problem with access to the user table. 

    [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

    mysqld --skip-grant-tables - it starts without reading the user table

    mysql_upgrade - then I could upgrade my tables

    killall mysqld - killing all the mysql instances

    4. Finally 

    # service mysqld start

    Edited by Peter Jablonski
  • 0
    Avatar
    Peter Debik

    MariaDB 10.2 is not yet officially supported. It is not causing issues in the panel, but the database repair tool claims that some date/timestamp fields are misconfigured, and it is unable to repair them. It would be good to add a check in the installation routines of Plesk to prohibit an installation on MariaDB 10.2. I only "accidentally" installed it on a 10.2 and found out about the wrong version in a recent support ticket.

  • 0
    Avatar
    Artyom Baranov

    @Peter Jablonski,

    Direct upgrade of MySQL 5.1 to MySQL 5.6/5.7 will damage tables (There is the warning message at the top of this article).

    It's strongly recommended to upgrade to MySQL 5.5 at first.

  • 0
    Avatar
    Definedhostinguk

    was upgrade from 5.5 to 5.7 on centos 6.9 and was getting mysql daemon failed to start when trying to restart mysql. Trawled through the web and finally came to a really quick fix. 

    # mysqld_safe

  • 0
    Avatar
    Vitaly Zhidkov

    @Artur, in case you need some specific version of MariaDB, you can specify it in repository configuration file in baseurl. For 10.0.27 for CentOS 7 it will be http://yum.mariadb.org/10.0.27/centos7-amd64

  • 0
    Avatar
    Vitaly Zhidkov

    @Definedhostinguk this can be only a workaround, not a fix. Check the /var/log/mysqld.log for error messages and search for articles in our Help Center

  • 0
    Avatar
    Bulat Tsydenov

    @Peter It would be great if you provide your suggestion on our Plesk User Voice. Thank you!

Please sign in to leave a comment.