How To Upgrade MariaDB Version 10.1 to 10.3

This short guide will show you how to upgrade MariaDB 10.1 to 10.3 in CentOS 7 Linux. We’ll start by modifying the repository file and perform a ‘yum update’. This may fail to automatically update the MariaDB-server package, so I’ll show you how to manually use the mysql_upgrade script to complete the process.

Upgrade MariaDB 10.1 to 10.3

First let’s check the current version of MariaDB that’s installed.

[root@centos7 ~]# mysql -V
mysql  Ver 15.1 Distrib 10.1.36-MariaDB, for Linux (x86_64) using readline 5.1

As we can see here we’re running MariaDB 10.1.36. This installed from a repository that I created some time ago, as shown below.

[root@centos7 ~]# cat /etc/yum.repos.d/mariadb.repo
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Now simply edit the .repo file that you’re using for MariaDB with your favourite text editor and change 10.1 to 10.3. In this case the baseurl line will now look like this after editing.

baseurl = https://yum.mariadb.org/10.3/centos7-amd64

Now to upgrade MariaDB, run the ‘yum update’ command. If this does not provide updates to your MariaDB packages, run ‘yum clean all’ then try again.

On my server, this started updating the MariaDB-client, MariaDB-common, MariaDB-server, and MariaDB-shared packages to the current latest 10.3.10 version. All packages successfully updated except for MariaDB-server, which failed.

Failed:
  MariaDB-server.x86_64 0:10.0.29-1.el7.centos 

The following information is then noted afterwards:

******************************************************************
A MySQL or MariaDB server package (MariaDB-server-10.1.36-1.el7.centos.x86_64) is installed.

Upgrading directly from MySQL 10.1 to MariaDB 10.3 may not
be safe in all cases.  A manual dump and restore using mysqldump is
recommended.  It is important to review the MariaDB manual's Upgrading
section for version-specific incompatibilities.

A manual upgrade is required.

- Ensure that you have a complete, working backup of your data and my.cnf
  files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages.  Usually this command will
  list the packages you should remove:
  rpm -qa | grep -i '^mysql-'

  You may choose to use 'rpm --nodeps -ev ' to remove
  the package which contains the mysqlclient shared library.  The
  library will be reinstalled by the MariaDB-shared package.
- Install the new MariaDB packages supplied by MariaDB Foundation
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process.  Important details
can be found in the MariaDB manual, in the Upgrading section.
******************************************************************
error: %pre(MariaDB-server-10.3.10-1.el7.centos.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package MariaDB-server-10.3.10-1.el7.centos.x86_64
MariaDB-server-10.1.36-1.el7.centos.x86_64 was supposed to be removed but is not!
  Verifying  : MariaDB-server-10.1.36-1.el7.centos.x86_64                                                                                                1/2
  Verifying  : MariaDB-server-10.3.10-1.el7.centos.x86_64                                                                                                2/2

Failed:
  MariaDB-server.x86_64 0:10.1.36-1.el7.centos                                  MariaDB-server.x86_64 0:10.3.10-1.el7.centos

Manual Update

So essentially we need to finish the process manually. This can be done by running the following commands in this order. Note that as recommended, you should first take a backup of all databases before proceeding, and also take a copy of the /etc/my.cnf file, as suggested in the output above.

systemctl stop mariadb
yum remove MariaDB-server
yum install MariaDB-server
systemctl start mariadb
mysql_upgrade -u root -p

This will stop MariaDB, remove the older 10.1 package, install the newer 10.3 version of the package as per the repository update earlier, start MariaDB, and then run the upgrade script. You’ll need to enter the password for the user specified when running the upgrade.

[root@centos7 ~]# mysql_upgrade -u root -p
Enter password:
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats                                 OK
... SNIP ...

The upgrade took about 10 seconds to complete for about 10 databases that were less than 500MB in total size for all of them, as the contents are checked for compatibility note that the time for this part could vary depending on your databases.

Now if we check our version of MariaDB again, we can see we’ve successfully upgraded to 10.1.

[root@centos7 ~]# mysql -V
mysql  Ver 15.1 Distrib 10.3.10-MariaDB, for Linux (x86_64) using readline 5.1

Summary

I’ve now shown you how to upgrade MariaDB 10.1 to 10.3. After updating the repository and running ‘yum update’, we need perform some additional manual steps as shown to complete the upgrade process.

  1. Thanks for the tip. It works perfectly.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>