+91 88 00 563434 [email protected] Blog open-book Knowledge Base

Find Solutions in Our Knowledge Base

How to upgrade the MariaDB or MySQL version in Linux

You are here:
Sharing is Caring

Upgrading MariaDB or MySQL Version in Linux

This tutorial will guide you through the process of upgrading 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 the Plesk control panel.

For Ubuntu 12.04 and 14.04, Debian 7:

By default, Ubuntu 14.04 comes with MySQL 5.5.

1) To begin, make a full server backup and create a backup of /etc/mysql/my.cnf:

# cp /etc/mysql/my.cnf

2) Next, download the Mysql APT Repository:

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

3) Install the downloaded package:

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

During the installation, you will be presented with several versions and components. It is recommended to keep the default options unless you have specific preferences for certain components. After making any necessary changes, select “apply” to finish the configuration and installation of the release package.

4) Update the package information from the MySQL APT repository:

# apt-get update

5) Upgrade the MySQL server:

# apt-get install mysql-server

If prompted to update /etc/mysql/my.cnf, choose the default option. Ensure that the mysql-community-libs-compact package is installed. If not, install it.

6) Upgrade MySQL databases:

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

7) Restart the MySQL server:

# service mysql restart

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

For CentOS 6:

1) First, stop the MySQL service:

# service mysqld stop

2) Create a backup of all databases by copying them to another directory:

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

3) Check if the Atomic repository is disabled:

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

enabled = 0

4) 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

For mysql56-community:

enabled=0

For mysql57-community:

enabled=1

6) Install MySQL packages:

# yum update mysql

If the update ends with a “Nothing to do” message, check if mysql* packages are excluded in the yum.conf file. Remove them if they are in the list. You can check if the line exists using the following command:

# cat /etc/yum.conf | grep exclude

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

If the line exists, remove it from yum.conf and proceed with the update.

If prompted, 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) Upgrade all 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 comes with MariaDB by default.

1) Create a backup of all databases:

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

2) Stop the MariaDB service:

# service mariadb stop

3) Remove additional packages like mariadb-bench:

# rpm -e mariadb-bench

4) Copy all databases to a separate directory:

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

5) Configure the MariaDB repository:

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

Select the OS distro as centos and release as centos 7. Then choose the desired MariaDB version. Add the provided configuration to the /etc/yum.repos.d/MariaDB.repo file.

For example, for MariaDB 10.3, the configuration would look like this:

# 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, proceed with the upgrade:

# yum install mariadb

7) Start the MariaDB service:

# service mariadb start

8) Update the package version inside Plesk:

# plesk sbin packagemng -sdf

Note that after upgrading to version 10.3, the ‘mysql’ init script may appear. You can remove it:

# rm /etc/init.d/mysql

# systemctl daemon-reload

For CloudLinux:

1) Create a backup of all databases:

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

2) Stop the MariaDB service:

# service mysql stop

3) Copy all databases to a separate directory:

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

4) Start the MariaDB service:

# service mysql start

5) Select the desired MariaDB version to install:

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

Replace “mariadbXX” with one of the following options:

mariadb100 for MariaDB v10.0

mariadb101 for MariaDB v10.1

mariadb102 for MariaDB v10.2

6) Install the selected MariaDB version:

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

7) Update the package version inside Plesk:

# plesk sbin packagemng -sdf

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


Sharing is Caring

Leave a Comment

Table of Contents