Introduction: Why Upgrading MariaDB on CWP Can Be Tricky
Keeping your server’s database up-to-date is a critical task for both security and performance. For administrators using Control Web Panel (CWP), the process to update MariaDB on CWP should be simple, but it often leads to frustrating package conflicts, especially on EL8 systems (AlmaLinux, Rocky Linux, etc.).
If you’ve seen errors like conflicts with mysql-server or file... conflicts with file from package mysql-common, you are not alone. This guide will walk you through the correct, professional methods to upgrade MariaDB successfully, ensuring a smooth and stable transition.
The Critical First Step: Backup Your Databases
Before you attempt any package update or version switch, you must perform a full backup of your databases. This is a non-negotiable first step.
Log in to your server via SSH as root and execute the following command:
Bash
mysqldump -u root -p --all-databases > /root/all_databases_backup.sql
You will be prompted for your MySQL/MariaDB root password. This command creates a single file in your /root/ directory containing all your database data.
Method 1: The CWP GUI (Recommended Method)
CWP provides a built-in tool that is designed to handle this upgrade. This script is intended to automatically manage package conflicts and should be your first choice.
- Log in to your CWP Admin Panel (port 2087).
- Navigate to SQL Services on the left-hand menu.
- Click on MySQL Version Switcher.
- You will see a list of available MariaDB versions. Select the version you wish to upgrade to (e.g., MariaDB 10.5).
- Click the “Rebuild MySQL” (or similar) button.
This process will take several minutes as CWP removes the old packages and installs the new ones from its own repository. If this completes successfully, you are done. However, if it fails or you are stuck in a bad update loop, proceed to the command-line fix.
Method 2: The Manual Command-Line Fix (for DNF Conflicts)This is the definitive solution for when the standard dnf update or the CWP script fails. These steps will manually resolve the exact package conflicts you may have encountered.
Step 1: Resolve the mariadb-backup Conflict
When you first try to run dnf update, you will likely encounter an error stating that the new MariaDB-server conflicts with the old mariadb-backup and mariadb-gssapi-server.
The Error:
Problem: package mariadb-backup... requires mariadb-server... but none of the providers can be installed
This error occurs because the old packages from the operating system’s repository have dependencies that prevent them from being automatically replaced.
The Solution: Use the --allowerasing flag to give dnf permission to remove these conflicting packages.
Bash
dnf update --allowerasing
Step 2: Resolve the mysql-common Conflict
In many cases, the update will fail a second time with a new error, this time a file conflict.
The Error:
Error: Transaction test error: file /usr/share/mysql/charsets/Index.xml from install of MariaDB-common... conflicts with file from package mysql-common...
This happens because your system also has a generic mysql-common package installed (from the OS appstream repository) which conflicts with the MariaDB-common package CWP is trying to install.
The Solution: You must manually remove the conflicting mysql-common package. This is safe, as the MariaDB packages will replace its functionality.
Bash
dnf remove mysql-common
The system will ask for confirmation, showing that it will also remove related packages like mysql-devel and mysql-libs. This is expected. Press y to continue.
Step 3: Run the Final Update
With all conflicts now cleared, you can run the update command one last time.
Bash
dnf update --allowerasing
This time, the command will successfully download the new MariaDB-server, MariaDB-client, and MariaDB-common packages from the cwp repository, remove all the old packages, and complete the installation.
Finalizing the Upgrade (Do Not Skip This!)
Your packages are now upgraded, but the database service itself needs two final actions to complete the process.
1. Restart the MariaDB Service You must restart the service for the new version to take effect.
Bash
systemctl restart mariadb
2. Run the Database Upgrade This is the most critical post-install step. The mysql_upgrade command inspects all of your existing databases and tables and updates their internal formats to be compatible with the new MariaDB version.
Bash
mysql_upgradeThis command will check and repair tables, ensuring there is no data corruption or incompatibility.
Conclusion
Successfully upgrading MariaDB on CWP is a process of resolving package repository conflicts. While the CWP MySQL Version Switcher is the preferred method, understanding how to use dnf remove mysql-common and dnf update --allowerasing is essential for any CWP administrator. By following these steps, you can confidently keep your database server secure, performant, and running the latest version.