Skip to content

Upgrading MariaDB 10.3 to 10.5 the long way

In case of mysql_upgrade not working here is what to do. I usually use the FreeBSD ports for mariaddbX-client and mariadbX-server .



Step 1) Back up the databases individually.



Based on https://phoenixnap.com/kb/how-to-backup-restore-a-mysql-database



here is the script I came up with



#!/usr/local/bin/bash

for DB in $(mysql --user=user --password="password" -e 'show databases' -s --skip-column-names); do

mysqldump --user=user --password="password" $DB > "$DB.sql";

done



advice create a non-root user as of MAriaDB 10.5 , root is unique and programmes like adminer and phpMyAdmin will not work with the root account.



Step 2) Compile a fresh new Mariadb client and servier in /var/db , I junk link mysql to whatever the current mariadb iteration is.



Step 3) One mysql is ready, login to Mysql then create the databases needed by mysql by typing mysqladmin -u user -p create databasename



Step 4) go into mysql using mysql -p then from https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql



CREATE USER 'databaseuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON database . * TO 'databaseuser'@'localhost';



Step 5) restore the databases using command line mysql -u user -p databasename < databasebackup.sql



Or restore via phpmyadmin or adminer or whatever tool you see fit.