Upgrade MariaDB or MySQL Version in Linux

Last modified: July 29, 2020
You are here:
Estimated reading time: 3 min

In this tutorial, you are going to upgrade your MariaDB version from 5.5 to 10.0/10.1/10.2 or MySQL from 5.5 to 5.6/5.7 on Linux and Plesk control panel.

 

For Ubuntu 12.04 and 14.04, Debian 7:

Ubuntu 14.04 it is already equipped with MySQL 5.5 by default.

1) Create a full server backup and also create a backup of /etc/mysql/my.cnf:

# cp /etc/mysql/my.cnf

2) Download the Mysql APT Repository:

# wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb

3) Now you have downloaded the release package you will need to Install the package:

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

There are plenty of versions available during the installation of the MySQL server along with other components which you prefer to install. If you are in a dilemma to opt a version, you are recommended to keep intact the default options endorsed for you. Meanwhile, if not enticed of any particular component, you can choose none as well. Furthermore, after making necessary changes for entire components, choose to apply to finish the configuration and installation of the release package, which is a mandatory step to be followed.

4) Update package information from the MySQL APT repository:

# apt-get update

5) Upgrade the MySQL server:

# apt-get install mysql-server

You can Agree when the system prompts to update /etc/mysql/my.cnf. You need to check that mysql-community-libs-compact package is installed if it is not installed you will need to install it.

6) Upgrade MySQL databases:

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

7) Restart MySQL server

# service mysql restart

8) In Plesk go to Tools & Settings > Server Components and click Refresh.

 

For CentOS 6:

1) First you need to stop the MySQL service using the following command:

# service mysqld stop

2) Create a backup of all databases, you need to copy these backup into any directory:

# cp -a /var/lib/mysql /var/lib/mysql_backup

3) Check whether Atomic repository is disabled:

# vi /etc/yum.repos.d/atomic.repo

enabled = 0

4) Now Install the MySQL-community repository:

# yum install http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm

5) Select a MySQL version:

# vi /etc/yum.repos.d/mysql-community.repo

If you want mysql56-community

enabled=0

For mysql57-community

enabled=1

6) Install MySQL packages:

# yum update mysql

If the 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. The following command checks whether such a line is included.:

# cat /etc/yum.conf | grep exclude

exclude=php-common php-cli php mysql* httpd* mod_ssl*

If the above such line occurs you need to remove it from the yum.conf and proceed with the updating.

If the following message appears type y:

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 <[email protected]>

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]:

7) Start the MySQL service:

# service mysqld start

8) In the next step upgrade all the MySQL databases:

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

9) Restart the mysql service:

# service mysqld restart

 

For CentOS 7:

CentOS 7 is already equipped with MariaDB by default.

1) Create a backup of all databases using the following command:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin –all-databases –routines –triggers > /tmp/all-databases.sql

2) Stop the MariaDB service using the following command:

# service mariadb stop

3) Remove additional packages like mariadb-bench:

# rpm -e mariadb-bench

4) Copy all the databases to a separate directory. You can run the following command for the same :

# cp -a /var/lib/mysql/ /var/lib/mysql_backup

5) Configure the MariaDB repository:

Go to the link mentioned in the following https://downloads.mariadb.org/mariadb/repositories/#mirror=harukasan&distro=CentOS&distro_release=centos7-amd64–centos7

Select OS distro as centos and release as centos 7. Then select the corresponding MariaDB version that you want to upgrade. Now you can see the configuration, this should be added to /etc/yum.repos.d/MariaDB.repo file

For example for MariaDB10.3 you will be getting the following configuration:

# MariaDB 10.3 CentOS repository list – created 2018-05-30 15:20 UTC

http://downloads.mariadb.org/mariadb/repositories/

[mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.3/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

6) After adding the configuration to /etc/yum.repos.d/MariaDB.repo file performs the upgrade with the following:

# yum install mariadb

7) Now start the MariaDB service:

# service mariadb start

8) Execute the following command to update the package version inside Plesk:

# plesk sbin packagemng -sdf

Please note after the upgrade to 10.3 version, there may appear ‘mysql’ init script. It can be removed:

# rm /etc/init.d/mysql

# systemctl daemon-reload

 

For CloudLinux

1) Create a backup of all databases using the following command:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin –all-databases –routines –triggers > /tmp/all-databases.sql

2) Stop the MariaDB service using the following command:

# service mysql stop

3) Copy all the databases to a separate directory. You can run the following command for the same:

# cp -a /var/lib/mysql/ /var/lib/mysql_backup

4) Now start the MariaDB service:

# service mysql start

5) In the next step you are going to select the MariaDB version to install:

# /usr/share/lve/dbgovernor/db-select-mysql –mysql-version=mariadbXX

For selecting the corresponding version, you should substitute “mariadbXX “with any one of the following:

mariadb100 for MariaDB v10.0

mariadb101 for MariaDB v10.1

mariadb102 for MariaDB v10.2

6) Now you have selected the MariaDB version you can now perform the installation process by running the following command

# /usr/share/lve/dbgovernor/mysqlgovernor.py –install

7) Execute this command to update the package version inside Plesk:

# plesk sbin packagemng -sdf

 

If you need any further assistance please contact our support department.

 

Was this article helpful?
Dislike 0
Views: 13