About Parker Services Clients Software and Publications Blog
Contact
PHM Sciences

Upgrading from MariaDB 10.2 to MariaDB 10.3 on CentOS 7

Just updated MariaDB from 10.2 to 10.3 on multiple servers using Red Hat’s Software Collections (https://www.softwarecollections.org/en/). Used the following commands. Might be of use to someone, good luck!

# Install MariaDB 10.3
yum install rh-mariadb103-mariadb-server
yum install rh-mariadb103-mariadb-server-utils

# Add MariaDB 10.3 to $PATH
scl enable rh-mariadb103 bash
source /opt/rh/rh-mariadb103/enable

# Stop 10.2 server, copy database, set permissions, start 10.3 server
systemctl stop rh-mariadb102-mariadb.service;
cp -r /var/opt/rh/rh-mariadb102/lib/mysql /var/opt/rh/rh-mariadb103/lib;
chown -R mysql:mysql /var/opt/rh/rh-mariadb103/lib/mysql;
systemctl start rh-mariadb103-mariadb

# Upgrade tables
mysql_upgrade -p[PASSWORD]

# Set 10.3 to start on boot, disable 10.2
systemctl disable rh-mariadb102-mariadb
systemctl enable rh-mariadb103-mariadb

# Add 10.3 to paths on reboot (and remove 10.2) 
rm /etc/profile.d/rh-mariadb102.sh
cp /opt/rh/rh-mariadb103/enable /etc/profile.d/rh-mariadb103.sh

Don’t forget to edit your new database configuration file, which is located at /etc/opt/rh/rh-mariadb103/my.cnf. Your old configuration will be at /etc/opt/rh/rh-mariadb102/my.cnf. The /my.cnf.d/ subdirectory at the same location may contain additional configuration files.

Upgrading from MariaDB 5.5 to MariaDB 10.2 on CentOS 7

By default, CentOS 7 uses MariaDB 5.5. Newer versions of MariaDB are available from Software Collections. Here is the code I used on a few different servers to change the SQL database version from MariaDB 5.5 to 10.2:

# Install MariaDB 10.2. You might need to add the Software Collections repo beforehand.
yum install rh-mariadb102-mariadb-server


# Stop MariaDB 5.5
# Copy databases to MariaDB 10.2
# Set owner
# Start MariaDB 10.2
systemctl stop mariadb; cp -r /var/lib/mysql /var/opt/rh/rh-mariadb102/lib; chown -R mysql:mysql /var/opt/rh/rh-mariadb102/lib/mysql; systemctl start rh-mariadb102-mariadb

# Add MariaDB 10.2 to path
scl enable rh-mariadb102 bash

# Check that PATH is set correctly
which mysql_upgrade

# If path to mysql_upgrade is /usr/bin/, then it wasn't successfully changed. Try running:
source /opt/rh/rh-mariadb102/enable

# Upgrade the copied databases
mysql_upgrade -p[PASSWORD]

# Disable MariaDB 5.5 to start on boot
systemctl disable mariadb

# Enable MariaDB 10.2 to start on boot
systemctl enable rh-mariadb102-mariadb

# Add MariaDB 10.2 to path on boot
cp /opt/rh/rh-mariadb102/enable /etc/profile.d/rh-mariadb102.sh

Don’t forget to edit your new database configuration file, which is located at /etc/opt/rh/rh-mariadb102/my.cnf. Your old configuration will be at /etc/my.cnf.

Good luck!