Upgrading MariaDB manually

Note: These instructions seem to be out of date/incomplete. Before we update the official doc, it would be good to have extra input. Please see the comments below for more information and post any issues/changes that you discover.


MariaDB 10.1 is depreciating in the upcoming weeks so Cyberpanel 2.0.3 will come with MariDB 10.5. New installation will be automatically based on that version and older version will be upgraded.

If you don’t see the latest version after upgrade or mariadb doesn’t work for you any more, here are the steps to fix that

  1. Make sure that the repo has been updated

cat /etc/yum.repos.d/mariadb.repo

If the output has 10.5 in the string you are okay to continue, if not, please edit the file and update it to 10.5

  1. Backup MariaDB’s configuration files

Run the following commands to backup the current configuration

cp /etc/my.cnf /etc/my.cnf.bak 
mkdir /etc/cnfbackup 
cp -R /etc/my.cnf.d/ /etc/cnfbackup/
  1. Remove the current version

Run these commands to remove MariaDB
For Centos

yum remove MariaDB-server MariaDB-client galera MariaDB-devel MariaDB-shared -y

For Ubuntu

apt remove MariaDB-server MariaDB-client galera MariaDB-devel MariaDB-shared -y

  1. Install MariaDB 10.5

For Centos

yum --enablerepo=mariadb -y install MariaDB-server MariaDB-client MariaDB-devel MariaDB-shared -y

For Ubuntu

apt install MariaDB-server MariaDB-client MariaDB-devel MariaDB-shared -y

  1. Restore the backed up files
cp -f /etc/my.cnf.bak /etc/my.cnf 
rm -rf /etc/my.cnf.d/ 
mv /etc/cnfbackup/my.cnf.d /etc/
  1. Enable and start MariaDB 10.5
systemctl enable mariadb
systemctl start mariadb
1 Like

@usmannasir As I detailed in this thread on the facebook group, MariaDB 10.3 is still installed with all versions of linux. The problem is that the distros haven’t updated their packages beyond 10.3, so the instructions you’ve provided here don’t help. You need to change the packages manually.

I think have finally properly upgraded to MariaDB v10.6 on Ubuntu 20.04. Here is what I did. The process should be similar for other OSs, but please be careful and post any variations that you discover below.

Note: there’s a lot of extra steps included here just to be extra thorough. For instance, it isn’t absolutely necessary to check the packages installed/uninstalled, check status of mariadb etc…

1. Review Official MariaDB Instructions

2. Backup

I didn’t take any backups, but the method written above by Usman or ones listed in the articles should work. Instead, I just made a snapshot of my entire server, which I DID end up needing once because something broke.

3. Config mariadb for proper shutdown

  • run cat /etc/cyberpanel/mysqlPassword to get your mariadb root password
  • run mysql -u root -p
  • enter password

Run these commands within mariadb cli

SET GLOBAL innodb_fast_shutdown = 1;
XA RECOVER;
exit;

4. Remove MariaDB

  • run systemctl stop mariadb
  • confirm it is stopped with systemctl status mariadb. The output is convoluted, but look for following lines
Active: inactive (dead) since Wed 2022-03-16 14:13:25 CST; 1s ago
Status: "MariaDB server is down"
  • run apt list --installed | grep -i -E "mariadb|galera" to confirm which packages will be removed
  • run apt remove "*mariadb*" "galera*" -y
  • run apt list --installed | grep -i -E "mariadb|galera" again to confirm all those packages were removed

5. Install New Version of MariaDB

  • run the following command, changing 10.6 for whichever version you would like to install.
curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.6"
  • run apt update
  • run apt install mariadb-server libmariadb-dev -y
  • when prompted with this, enter N
Configuration file '/etc/mysql/mariadb.conf.d/50-server.cnf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** 50-server.cnf (Y/I/N/O/D/Z) [default=N] ?
  • run apt update && apt upgrade -y to update all packages again (there’s a mysql-common package that got updated from 5.8 to 10.6.7 for me)

  • run apt list --installed | grep -i -E "mariadb|galera" to confirm which packages were installed
    Note: don’t worry that libmariadbclient-dev is not installed as it was before. It appears to have been deprecated/replaced by libmariadb-dev, which was installed.

  • run systemctl enable mariadb

  • run systemctl start mariadb

  • run systemctl status mariadb to confirm version and active

  • run mysql_upgrade -u root -p.

This is CRITICAL, and not mentioned in the method above. Here are detailed investigations into what mysql_upgrade does

  • enter password from previously

Note: it might be worth upgrading CyberPanel after all of this. It is harmless, might pre-emptively fix any issues, and might even give you some minor updates that have not yet been included in an official release. Run

sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh) 

as per the instructions here Upgrading CyberPanel - Docs

2 Likes

Great info @nick.chomey . But you missed to mention about the file /etc/mysql/mariadb.conf.d/50-server.cnf' which it will ask whether to keep the old file or the replace it with new.

1 Like

Ah, yes. Thanks. I kept the old file (default setting) - is that correct?

What we really need to do is update Usman’s original Documentation post in this topic, as its a very important topic. But it should also include instructions for RHEL, which I don’t know anything about.

The topic is a Wiki Post, which means you/anyone can edit it. Do you think you could take what I’ve written, add what is necessary for RHEL, and make any other relevant changes?

Also, please see the comment I just made here about MariaDB errors that are ONLY occurring when CyberPanel is installed on Ubuntu (no issue when using Ubuntu without CP). MariaDB errors on Ubuntu 20.04 ONLY when using CyberPanel - Support and Discussion / General Discussion - CyberPanel Community

1 Like

Try this way on almalinux 8, but it will also remove pure-ftpd ?