Moving from MySQL to MariaDB in Debian 9

You are viewing an old version of this article. View the current version here.

MariaDB 10.1 is now the default mysql server in Debian 9 "Stretch". This page provides information on this change and instructions to help with upgrading your Debian 8 "Jessie" version of MySQL or MariaDB to MariaDB 10.1 in Debian 9 "Stretch".

Background information

The version of MySQL in Debian 8 "Jessie" is 5.5. When installing, most users will install the mysql-server package, which depends on the mysql-server-5.5 package. In Debian 9 "Stretch" the mysql-server package depends on a new package called default-mysql-server. This package in turn depends on mariadb-server-10.1. There is no default-mysql-server package in Jessie.

In both Jessie and Stretch there is also a mariadb-server package which is a MariaDB-specific analog to the mysql-server package. In Jessie this package depends on mariadb-server-10.0 and in Stretch this package depends on mariadb-server-10.1 (the same as the default-mysql-server package).

So, the main repository difference in Debian 9 "Stretch" is that when you install the mysql-server package on Stretch you will get MariaDB 10.1 instead of MySQL, like you would with previous versions of Debian.

All apps and tools, such as the popular LAMP stack, in the repositories that depend on the mysql-server package will continue to work using MariaDB as the database. For new installs there is nothing different that needs to be done when installing the mysql-server or mariadb-server packages.

Before you upgrade

If you are currently running MySQL 5.5 on Debian 8 "Jessie" and are planning an upgrade to Debian 9 "Stretch", there are some things to keep in mind:

First, this is a major upgrade, and so complete database backups are strongly suggested before you begin. Even if MariaDB 10.1 is compatible on disk and wire with MySQL 5.5 and the MariaDB developer team is doing the best it can to deliver pain free upgrades, it's always a good idea to do a backup from time to time. As the database has to shutdown anyway for the upgrade, now you have a good opportunity to do a backup!

Second, the Upgrading MariaDB section contains several articles on upgrading from MySQL to MariaDB and from one version of MariaDB to another. For upgrade purposes, MySQL 5.5 and MariaDB 5.5 are very similar. In particular, see the Upgrading from MariaDB 5.5 to MariaDB 10.0 and Upgrading from MariaDB 10.0 to MariaDB 10.1 articles. Both of these detail the changes in the values of default options between the releases. Review the lists to determine if you want to change them from the new defaults in your local my.cnf file.

If you have a master-slave setup, the normal procedure is to first upgrade your slaves to MariaDB, then move one of your slaves to be the master and then upgrade your original master. In this scenario you can upgrade from MySQL to MariaDB or upgrade later to a new version of MariaDB without any downtime.

If you need help with upgrading or setting up replication, you can always contact the MariaDB corporation to find experts to help you with this.

Upgrading to MariaDB 10.1 from MySQL 5.5

The suggested upgrade procedure is:

  1. Set innodb_fast_shutdown to 0. This is to ensure that if you make a backup as part of the upgrade, all data is written to the InnoDB data files, which simplifies any restore in the future.
  2. Shutdown MySQL 5.5
  3. Take a backup
    • when the server is shut down is the perfect time to take a backup of your databases
    • store a copy of the backup on external media or a different machine for safety
  4. Perform the upgrade from Debian 8 to Debian 9
  5. During the upgrade, the mysql_upgrade script will be run automatically; this script does two things:
    1. Upgrades the permission tables in the mysql database with some new fields
    2. Does a very quick check of all tables and marks them as compatible with MariaDB 10.1
      • In most cases this should be a fast operation (depending of course on the number of tables)
  6. Add new options to my.cnf to enable features
    • If you change my.cnf then you need to restart mysqld with e.g. sudo service mysql restart or sudo service mariadb restart.

Upgrading to MariaDB 10.1 from an older version of MariaDB

If you have installed MariaDB 5.5 or MariaDB 10.0 on your Debian 8 "Jessie" machine from the MariaDB repositories you will need to upgrade to MariaDB 10.1 when upgrading to Debian 9 "Stretch". You can choose to continue using the MariaDB repositories or move to using the Debian repositories.

If you want to continue using the MariaDB repositories edit the MariaDB entry in your sources.list and change every instance of 5.5 or 10.0 to 10.1. Then upgrade as suggested above.

If you want to move to using MariaDB 10.1 from the Debian repositories, delete or comment out the MariaDB entries in your sources.list file. Then upgrade as suggested above.

If you are already using MariaDB 10.1 on your Debian 8 "Jessie" machine, you can choose to continue to use the MariaDB repositories or move to using the Debian repositories as with MariaDB 5.5 and 10.0. In either case, the upgrade will at most be just a minor upgrade from one version of MariaDB 10.1 to a newer version. In the case that you are already on the current version of MariaDB that exists in the Debian repositories or a newer one) MariaDB will not be upgraded during the system upgrade but will be upgraded when future versions of MariaDB are released.

You should always perform a compete backup of your data prior to performing any major system upgrade, even if MariaDB itself is not being upgraded!

MariaDB Galera Cluster

If you have been using MariaDB Galera Cluster 5.5 or 10.0 on Debian 8 "Jessie" it is worth mentioning that Galera Cluster is included by default in MariaDB 10.1, there is no longer a need to install a separate mariadb-galera-server package.

Configuration options for advanced database users

To get better performance of MariaDB used in production environments, here is some suggested additions to your configuration file which in Debian is at /etc/mysql/mariadb.d/my.cnf:

[[mysqld]]
# Cache for disk based temporary files
aria_pagecache_buffer_size=128M
# If you are not using MyISAM tables directly (most people are using InnoDB)
key_buffer_size=64K

The reason for the above change is that MariaDB is using the newer Aria storage engine for disk based temporary files instead of MyISAM. The main benefit of Aria is that it can cache both indexes and rows and gives thus better performance than MyISAM for large queries.

See also

Comments and suggestions

If you have comments or suggestions on things we can add or change to improve this page. Please add them as comments below.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.