Reading Time: 3 minutes
MariaDB is quickly becoming the default open-source database software to use in development, production, and even enterprise environments. Our very own Cloud Sites product
uses the newest in MariaDB as it’s mostly known for being a fork and drop-in replacement to MySQL, which is created and maintained by the original MySQL developers.
This article aims to provide advice and insight when it comes to upgrading from MariaDB 10.0 to 10.3.9 on Ubuntu 16.04. The first question that is likely already on your mind is, “Is it safe to jump and skip from one version to another?” While the whole jump is possible (depends on the database’s data structure) it’s not recommended and based on the official documentation, is not supported. The main concern with skipping versions is while upgrading one major version is usually well-tested, skipping versions is not, so one may bump into an incompatibility. It is suggested to carefully go through the changes in each release to see if any changes could affect the database that is being upgraded.
The following page is from MariaDB’s official website and documentation on upgrading MariaDB
. As you can see, their documentation shows upgrades in sequential order as this is the preferred method of upgrading.
However, the administrator who is being tasked with making the upgrade should definitely consult the documentation for any change logs that have been documented per the version being upgraded to. These pages will include all the need to know information regarding the versions being upgraded to. These pages typically include any prerequisites, how to upgrade, incompatible changes between the former and new version being updated too, options that have been removed or renamed, and other noteworthy features and changes.
Upgrading on Ubuntu 16.04
We will first look at the steps needed to upgrade on Ubuntu 16.04. Most of what we’ll be covering requires the use of ‘sudo
’. Myself, I like to have all my ducks in a row before doing a single step at a time. Since we’re going to be doing multiple version upgrades, and we know the version we want to ultimately upgrade to, we’ll need to ensure that we have configured our /etc/apt/sources.list
file with where we’ll be installing the upgraded versions from. When deciding our download source, we recommend to always consult the author’s documentation on suggested download sources. The following page allows one to specify their specific criteria for their specific trusted download source
Once the selections have been applied, it is time to add the repositories to the servers /etc/apt/sources.list
file. For our Ubuntu example, we’re using the ‘osuosl’ repo.
Rinse and repeat this process for versions 10.1-10.3. Once all the applicable repos have been added to the /etc/apt/sources.list
file. You’ll also need to edit the file and uncomment the newly added repos. Do one at a time, per each version upgrade. Now we can begin the actual upgrade process from 10.0 to 10.1.
Step 1. Set innodb_fast_shutdown to 0
When logged into the database, the command to issue is below:
Step 2. Shutdown MariaDB 10.0
Stopping the service is necessary to upgrade MariaDB instances.
Step 3. Take a Backup
You have the choice of backing up your MariaDB instance either through the cp
command. The best way to grab a pristine copy of any MySQL / MariaDB server, is to stop the service completely (i.e. Step 2) and make a copy of /var/lib/mysql
cp /var/lib/mysql nameofbackup
Alternatively, you can also run the command below while the server is still running, then shut down MySQL and re-run the rsync to get the latest differences.
rsync -avHP /var/lib/mysql/ /backup/mysql/
Step 4. Uninstall MariaDB 10.0
The command below will allow you to remove MariaDB 10.0:
sudo apt remove mariadb-server-10.0
When removing 10.0 you’ll see the output similar to this screenshot.
Step 5. Install MariaDB 10.1
After 10.0 has been removed, it is now time to upgrade to 10.1. When installing, you should see similar text appear. Specifically, you should be seeing the package being downloaded from the repo that was configured in /etc/apt/sources.list
If done successfully, the next prompt you’ll see should look similar to this:
Step 6. MariaDB version check
Since we are running Ubuntu (the same applies for other Debian packages), we will not need to execute the run mysql_upgrade command. To verify the version that the server is now on, run:
Step 7. Add new options to my.cnf to enable features
If you change the my.cnf
file then you need to restart the mysqld service:
service mysqld restart
Rinse and repeat until successfully installed to the required/ updated version of MariaDB 10.3.