How to safely upgrade from MariaDB 10.x to 10.3 without losing data A quick tutorial explaining how to perform a seamless upgrade from a previous version of MariaDB 10 to MariaDB 10.3 keeping all the existing databases intact

Come installare MariaDB 10.x su CentOS 7.x e metterlo in sicurezza per l'utilizzo in produzione
Post updated to MariaDB 10.3.13-GA release, released on February 21, 2019 (release notes).

It has been a while since MariaDB 10.3 has been out, bringing its stunning pack of changes, improvements and new features - most notably, System-versioned tables and Sequences. If you found this post on Google, there's a high chance you want to upgrade your previous version of MariaDB and take advantage of these awesome new feats.

In this article, we'll see how we can safely update any existing 10.0, 10.1 or 10.2 MariaDB instance with the new MariaDB 10.3 - more specifically, MariaDB 10.3.13-GA, which has been released on 2018-07-03 and is the latest stable version as of today. The steps below have been tested on a Linux CentOS 7 machine, but can be used - or slightly adapted by replacing yum with apt-get - with most Linux distributions.

#1: Perform a full backup

The first thing to do is to perform a full backup of the whole MariaDB server instance. To do so, I strongly suggest you to read this MySQL/MariaDB backup tutorial using the free mysqldump command-line tool. In very short words, here's the one-liner:

If everything goes well, you won't need this backup: however, since we're performing a DB upgrade here, it's better to be safe than sorry.

#2: Shutdown the existing MariaDB service

The next thing to do is to shutdown the existing MariaDB server. This can be done with the following command:

#3: Uninstall the old MariaDB version

This step might sound scary, but don't worry: your existing databases and your current my.cnf file won't be deleted, only the binaries will.

#4: Configure the MariaDB 10.3 repository

As soon as the previous MariaDB instance is gone, we need to install the new version: in order to do that, we need to tell our Linux machine where to find the updated binaries. If you're using CentOS, RHEL or another yum-based distribution, you can easily do that by creating a new MariaDB10.repo file to the /etc/yum.repos.d/ folder and filling it with  the following content:

For additional info regarding the YUM repository syntax, check out this YUM and YUM Repositories guide from the official RHEL documentation.

In case you already have a MariaDB.repo, MariaDB10.repo or some other .repo file pointing to the old binaries, you might as well update it with the new 10.3 URIs.

#5: Install the new MariaDB 10.3 build

Now that yum will find the new binaries, we can proceed installing the new MariaDB server with the following command:

This will install both the client and the server.

How to safely upgrade from MariaDB 10.x to 10.3 without losing data

#6: Start and Enable the new MariaDB service

Once the installation job is complete, you can restart and enable the new MariaDB server with the following commands:

#7: Upgrade your existing database(s)

Last but not least, you need to run the mysql_upgrade command to upgrade the permission tables in the mysql database with some new fields:

This command will also perform a very quick check of all tables and marks them as compatible with MariaDB 10.3.

Conclusion

That's about it: I sincerely hope that this small tutorial will help you upgrading to MariaDB 10.3 and enjoy its new exciting features!

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

6 Comments on “How to safely upgrade from MariaDB 10.x to 10.3 without losing data A quick tutorial explaining how to perform a seamless upgrade from a previous version of MariaDB 10 to MariaDB 10.3 keeping all the existing databases intact

  1. Pingback: Free MySQL MariaDB command-line Backup using mysqldump
  2. Pingback: Backup di MySQL o MariaDB database da command-line con mysqldump
  3. Commands to enable mariadb in step 6

    sudo systemctl start mariadb
    sudo systemctl enable mariadb

  4. In my case when I ran mysql_upgrade I received an 1045 error. In order to get around this I simply ran mysql_upgrade –password

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.