How to upgrade MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.0/10.1/10.2 on Linux
Table of contents
This article provides instructions about how to upgrade MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.0/10.1/10.2 on Linux.
The instructions for upgrading MySQL from 5.1 to 5.5 on Linux see in the KB article:
Warning: Direct upgrade from 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 interface with the instructions below at your own risk. This task is supposed to be performed by a system administrator.
Note: MySQL will not be upgraded in case it installed from webtatic repository:
# rpm -qa | grep -i mysql
mysql55w-server-5.5.57-1.w6.x86_64
First of all, connect to the server via SSH.
For Ubuntu 12.04 and 14.04, Debian 7:
Ubuntu 14.04 is shipped with MySQL 5.5 by default.
-
- Create a full server backup and a server snapshot.
- Create a backup of
/etc/mysql/my.cnf
:# cp /etc/mysql/my.cnf{,_original}
- 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 a release package for your platform:
# wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb
- Install the downloaded release package:
# dpkg -i mysql-apt-config_0.8.9-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 noneif 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
- Upgrade MySQL:
# apt-get install mysql-server
Agree when prompted to update
/etc/mysql/my.cnf
. - Make sure that mysql-community-libs-compat package is installed. Install if it is missing.
- Upgrade MySQL databases:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin
- Restart MySQL server
# service mysql restart
- In Plesk go to Tools & Settings > Server Components and click Refresh.
More information available in MySQL documentation at http://dev.mysql.com/.
For CentOS 6:
-
-
- Stop the MySQL service:
# service mysqld stop
- Create a backup of databases:
# cp -a /var/lib/mysql /var/lib/mysql_backup
- Disable Atomic repository, if it is enabled:
# vi /etc/yum.repos.d/atomic.repo
enabled = 0 - Install the MySQL-community repository:
# yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
- Select a MySQL version:
# vi /etc/yum.repos.d/mysql-community.repo
[mysql56-community]
enabled=0
[mysql57-community]
enabled=1 - 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 inyum.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* - Type y if this message appears:
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]: - Start the MySQL service:
# service mysqld start
If the service does not start, check the following article: MySQL fails to start: mysql.user table is damaged.
- Upgrade MySQL databases:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin
- Restart mysql service:
# service mysqld restart
- Stop the MySQL service:
-
For CentOS 7:
CentOS 7 is shipped with MariaDB. MariaDB 10.x version is a drop-in replacement for MySQL 5.5-5.7.
-
-
- Create a backup of all databases with the following command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin –all-databases –routines –triggers > /tmp/all-databases.sql
- Stop the MariaDB service:
# service mariadb stop
- Remove additional packages like mariadb-bench:
# rpm -e mariadb-bench
- Copy a databases directory in a separate folder like this (for backup purposes also):
# cp -a /var/lib/mysql/ /var/lib/mysql_backup
- Configure MariaDB repository: open the Setting MariaDB repositories page, select OS distro, release and MariaDB version to see the configuration that should be added to /etc/yum.repos.d/MariaDB.repo file. Example for MariaDB10.1:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1 - Perform an upgrade with:
# yum install mariadb
- Start the MariaDB service:
# service mariadb start
- Upgrade MySQL databases:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin
- Restart mysql service:
# service mariadb restart
- Execute this command to update the package version inside Plesk:
# plesk sbin packagemng -sdf
Note: After an upgrade to 10.1 version, there may appear ‘mysql’ init script. It can be removed:
# rm /etc/init.d/mysql
# systemctl daemon-reload
- Create a backup of all databases with the following command:
-
For CloudLinux
-
-
- Create a backup of all databases with the following command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin –all-databases –routines –triggers > /tmp/all-databases.sql
- Stop the MySQL service:
# service mysql stop
- Copy a databases directory in a separate folder like this (for backup purposes also):
# cp -a /var/lib/mysql/ /var/lib/mysql_backup
- Start the MySQL service:
# service mysql start
- Select MariaDB version to install:
# /usr/share/lve/dbgovernor/db-select-mysql –mysql-version=mariadbXX
Note:
mariadbXX
should be substituted with one of the following:
mariadb100
for MariaDB v10.0
mariadb101
for MariaDB v10.1 - Install selected previously MariaDB engine:
# /usr/share/lve/dbgovernor/mysqlgovernor.py –install
Warning: CloudLinux do not recommend to downgrade from MySQL v5.6, MariaDB 10.x
- Execute this command to update the package version inside Plesk:
# plesk sbin packagemng -sdf
- Create a backup of all databases with the following command:
-
For Debian 8
Debian 8 is basically shipped with MariaDB. MariaDB 10.x version is a drop-in replacement for MySQL 5.5/5.6/5.7
Backup all existing databases using the 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