Moving from MySQL to MariaDB in Debian 9

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. Note that mysql-server is just an empty transitional meta-package and users are encouraged to install MariaDB using the actual package mariadb-server.

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 MariaDB 10.1 on Debian 9 "Stretch", there are some things to keep in mind:

Backup before you begin

This is a major upgrade, and so complete database backups are strongly suggested before you begin. MariaDB 10.1 is compatible on disk and wire with MySQL 5.5, and the MariaDB developer team has done extensive development and testing to make upgrades as painless and trouble-free as possible. Even so, it's always a good idea to do regular backups, especially before an upgrade. As the database has to shutdown anyway for the upgrade, this is a good opportunity to do a backup!

Changed, renamed, and removed options

Some default values have been changed, some have been renamed, and others have been removed between MySQL 5.5 and MariaDB 10.1. The following sections detail them.

Options with changed default values

Most of the following options have increased a bit in value to give better performance. They should not use much additional memory, but some of them do use a bit more disk space.

OptionOld default valueNew default value
aria-sort-buffer-size128M256M
back_log50150
innodb-concurrency-tickets5005000
innodb-log-file-size5M48M
innodb_log_compressed_pagesONOFF
innodb-old-blocks-time01000
innodb-open-files300400 [2]
innodb-purge-batch-size20300
innodb-undo-logsON20
join_buffer_size128K256K
max_allowed_packet1M4M
max-connect-errors10100
max-relay-log-size01024M
myisam-sort-buffer-size8M128M
optimizer-switch...Added extended_keys=on, exists_to_in=on
query_alloc_block_size819216384
query_cache_size01M
query_cache_typeONOFF
query_prealloc_size819224576
secure_authOFFON
sql_log_binNo longer affects replication of events in a Galera cluster.
sql_modeemptyNO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
sync_master_info010000
sync_relay_log010000
sync_relay_log_info010000
table_open_cache4002000
thread_pool_max_threads5001000

Options that have been removed or renamed

The following options should be removed or renamed if you use them in your config files:

OptionReason
engine-condition-pushdownReplaced with set optimizer_switch='engine_condition_pushdown=on'
innodb-adaptive-flushing-methodRemoved by XtraDB
innodb-autoextend-incrementRemoved by XtraDB
innodb-blocking-buffer-pool-restoreRemoved by XtraDB
innodb-buffer-pool-pagesRemoved by XtraDB
innodb-buffer-pool-pages-blobRemoved by XtraDB
innodb-buffer-pool-pages-indexRemoved by XtraDB
innodb-buffer-pool-restore-at-startupRemoved by XtraDB
innodb-buffer-pool-shm-checksumRemoved by XtraDB
innodb-buffer-pool-shm-keyRemoved by XtraDB
innodb-checkpoint-age-targetRemoved by XtraDB
innodb-dict-size-limitRemoved by XtraDB
innodb-doublewrite-fileRemoved by XtraDB
innodb-fast-checksumRenamed to innodb-checksum-algorithm
innodb-flush-neighbor-pagesRenamed to innodb-flush-neighbors
innodb-ibuf-accel-rateRemoved by XtraDB
innodb-ibuf-active-contractRemoved by XtraDB
innodb-ibuf-max-sizeRemoved by XtraDB
innodb-import-table-from-xtrabackupRemoved by XtraDB
innodb-index-statsRemoved by XtraDB
innodb-lazy-drop-tableRemoved by XtraDB
innodb-merge-sort-block-sizeRemoved by XtraDB
innodb-persistent-stats-root-pageRemoved by XtraDB
innodb-read-aheadRemoved by XtraDB
innodb-recovery-statsRemoved by XtraDB
innodb-recovery-update-relay-logRemoved by XtraDB
innodb-stats-auto-updateRenamed to innodb-stats-auto-recalc
innodb-stats-update-need-lockRemoved by XtraDB
innodb-sys-statsRemoved by XtraDB
innodb-table-statsRemoved by XtraDB
innodb-thread-concurrency-timer-basedRemoved by XtraDB
innodb-use-sys-stats-tableRemoved by XtraDB
rpl_recovery_rankUnused in 10.0+
xtradb-admin-commandRemoved by XtraDB

Suggested upgrade procedure for replication

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.

Other resources to consult before beginning your upgrade

It may also be useful to check out the Upgrading MariaDB section. It 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.

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 from MariaDB used in production environments, here are 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 thus gives better performance than MyISAM for large queries.

Secure passwordless root accounts only on new installs

Unlike the old MySQL packages in Debian, MariaDB 10.0 onwards in Debian uses unix socket authentication on new installs to avoid root password management issues and thus be more secure and easier to use with provision systems of the cloud age.

This only affects new installs. Upgrades from old versions will continue to use whatever authentication and user accounts already existed. This is however good to know, because it can affect upgrades of dependant systems, typically e.g. require users to rewrite their Ansible scripts and similar tasks. The new feature is much easier than the old, so adjusting for it requires little work.

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.

Notes

  1. The innodb-open-files variable defaults to the value of table-open-cache (400 is the default) if it is set to any value less than 10 so long as innodb-file-per-table is set to 1 or TRUE (the default). If innodb_file_per_table is set to 0 or FALSE and innodb-open-files is set to a value less than 10, the default is 300

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.