How to upgrade MariaDB from 10.0 to 10.1 to 10.2 on Ubuntu Linux

|

|

For Ubuntu 16.04 LTS and 17.10 users running MariaDB 10.0 or 10.1, an upgrade to MariaDB 10.2 is recommended before updating to Ubuntu 18.04. The upgrade offers new features and ensures full support as it’s the default database version in Ubuntu 18.04. The process involves preparing MariaDB for upgrade, backing up databases, uninstalling the prior…

This article explains how to upgrade MariaDB on Ubuntu Linux.

Those still running Ubuntu 16.04 LTS and 17.10 with MariaDB 10.0 or 10.1 installed and hoping to upgrade to Ubuntu 18.04 may want to upgrade the MariaDB database server to version 10.2 as it’s the default database version that comes with Ubuntu 18.04 and fully supported.

Upgrading MariaDB to newer versions is important for many reasons. Firstly, newer versions have improved performance, enhanced security features, and bug fixes. Additionally, every subsequent release of MariaDB adds new features and functions, so upgrading to the latest version can help you take advantage of these features.

Finally, if you plan to upgrade your operating system, like Ubuntu, to a newer version, upgrading MariaDB to a compatible version is important to ensure it runs smoothly.

If you decide on the upgrade, the steps below should be a great place to start.

Prepare MariaDB for Upgrade

Before upgrading MariaDB, the command below may be necessary. The commands below set innodb_fast_shutdown to 0. If you don’t do that, you may run into trouble where the upgrade hangs and may not go as planned.

To prepare MariaDB for Upgrade, log to the database server as root with the root password and run the commands below

sudo mysql -u root -p

Then run the commands below to set innodb_fast_shutdown to 0

mysql> SET GLOBAL innodb_fast_shutdown = 0;

Backup Your Databases

Now that you’ve prepared MariaDB to upgrade correctly, continue below. It’s always important to back up your databases before attempting to upgrade. On Linux systems, the mysqldump command can be used to back up MariaDB databases. To backup, run the commands below against each database you wish to backup.

sudo mysqldump -u root -p database_name > backup_database.sql

Replace database_name with the actual database you wish to backup. Do that on all your databases.

Uninstall MariaDB 10.0 or 10.1

Now that you’ve taken a backup of your databases, you can continue to uninstall the older version of MariaDB. To do that, run the commands below.

First, stop the database and uninstall it.

On Ubuntu 16.04, run the commands below.

sudo systemctl stop mysql.service

On Ubuntu 17.10 and up, run the commands below:

sudo systemctl stop mariadb.service

Then, run the commands below to uninstall MariaDB.

sudo apt remove mariadb-server

Install MariaDB Newer Versions

After uninstalling the older version, you can install MariaDB’s newer versions using the repository below.

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

For MariaDB 10.1, add the repository below:

sudo sh -c "echo 'deb [arch=amd64,i386] https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB-10.1.list"

For MariaDB 10.2, add the storage below:

sudo sh -c "echo 'deb [arch=amd64,i386] https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB-10.2.list"

After adding the package repositories, run the commands below to install the newer version of MariaDB based on the hold you added to your systems.

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client

Next, run the commands below to upgrade

sudo mysql_upgrade

Your server should be upgraded to the newer version if everything is correct.

Enjoy!

You  may also like the post below:

Like this:



9 responses to “How to upgrade MariaDB from 10.0 to 10.1 to 10.2 on Ubuntu Linux”

  1. Josh Avatar
    Josh

    Thank you! Needed this for a quick prod db upgrade. Only hangup was that the install process asked to created a root password, and if you do, the `upgrade_mysql` command will fail unless you have that in your `my.cnf` file. I ended up removing the root pw just to get the upgrade done!

  2. James Watkins Avatar
    James Watkins

    This article uses a non-standard repo from “evowise.com” and you should always be very cautious about using a non-standard repo, unless you really trust the source. Because you’re basically giving them the keys to the kingdom by running their software as root. And you may not even realize it. Official repositories can be found here: https://downloads.mariadb.org/mariadb/repositories

    1. davidbla Avatar
      davidbla

      apt will check the signatures in its default. you have to add their key and “their” means mariadbs.
      this will secure integrity of the files.

  3. MD Avatar
    MD

    Thank you, worked like a charm.
    Last step with mysql_upgrade is optional, but if it complains for the password just run it with -p like this: ‘mysql_upgrade -p’ then enter the root password

    1. Brad Avatar
      Brad

      mysql_upgrade -p did not work for me. I got the error “ERROR 1524 (HY000): Plugin ‘unix_socket’ is not loaded”. I did find this solution on askubuntu, though: https://askubuntu.com/questions/705458/ubuntu-15-10-mysql-error-1524-unix-socket

  4. DavidBla Avatar
    DavidBla

    Hi, it just raises this issue “skipping acquire of configured file ‘main/binary-i386/Packages’ as repository ‘https://mirrors.evowise.com/mariadb/repo/10.4/ubuntu bionic InRelease doesn’t support architecture ‘i386′”

    Don’t know why – the servers architecture is amd64.

    1. davidbla Avatar
      davidbla

      added [ arch=amd64 ] to circumvent the error message.

  5. Markus Avatar
    Markus

    Thank you!

  6. Rimple Avatar
    Rimple

    Perfect Explanation.
    sudo mysql_upgrade => sudo mysql_upgrade – u [username] -p

Leave a Reply to James Watkins Cancel reply

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

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