How to upgrade MariaDB safely (backup, repository, mariadb-upgrade, rollback)
MariaDB releases have limited support, and older ones stop receiving security fixes. A minor update is routine, but a move to a newer release should be done with a backup you have tested and the applications paused.
Check the version and who connects
Applications must be stopped or in maintenance during a release change.
mariadb --version sudo mariadb -e "SHOW PROCESSLIST"Back up everything
A logical backup with routines and events, plus the configuration.
sudo mariadb-dump --all-databases --routines --events --single-transaction > ~/mariadb-all-$(date +%F).sql sudo cp -a /etc/mysql ~/mariadb-etc-backup ls -lh ~/mariadb-all-*.sqlGo one supported release at a time
Choose the target on the MariaDB downloads page and add its repository, following the instructions for your distribution.
sudo apt-get update sudo apt-get install --only-upgrade mariadb-server mariadb-clientRun the upgrade tool
The package usually does this when the server restarts, but running it confirms that every table is in the new format.
sudo mariadb-upgrade sudo systemctl restart mariadb mariadb --versionTest the applications
Start them and test the main flows. Watch the error log.
sudo journalctl -u mariadb -n 30 --no-pager
Common mistakes
- Skipping the backup test: restore it to a spare server once.
- Upgrading replicas after the primary instead of before.
- Old application drivers that cannot use the new authentication defaults.
How to undo it
A release change cannot be undone in place: restore the dump into a fresh server of the old version.
Sources
Commands are for Debian and Ubuntu unless noted. Test on a copy first and keep a backup: you are responsible for changes on your own systems.