Skip to content

MySQL 8.4 package upgrade fails on Ubuntu 26.04 due to custom datadir (/home/mysql) #835

Open

Description

@matthieu2607

CloudPanel version(s) affected

2.5.4

Description

On a CloudPanel server running Ubuntu 26.04 LTS with MySQL 8.4, the mysql-server package fails during its post-installation configuration when upgrading to version 8.4.11-0ubuntu0.26.04.1.

The issue is caused by a mismatch between the MySQL data directory used by CloudPanel (/home/mysql) and the directory checked by Ubuntu's package post-installation script (/var/lib/mysql).

MySQL continues to operate normally, but the mysql-server package remains in a half-configured state, preventing APT from completing package management operations.

This issue may affect future MySQL security updates on CloudPanel installations using a custom data directory.

How to reproduce

Environment

  • OS: Ubuntu 26.04 LTS
  • Control panel: CloudPanel
  • MySQL: 8.4.11 (8.4.11-0ubuntu0.26.04.1)
  • Actual MySQL data directory: /home/mysql
  • Ubuntu package state directory: /var/lib/mysql

Steps to reproduce

  1. Use a CloudPanel installation with MySQL 8.4 configured to store its databases in /home/mysql.
  2. Verify that /var/lib/mysql exists but is empty.
  3. Upgrade the mysql-server package to version 8.4.11-0ubuntu0.26.04.1 using APT.
  4. Observe the package configuration failure.

Actual behavior

The installation fails with:

Setting up mysql-server (8.4.11-0ubuntu0.26.04.1)…
dpkg: error processing package mysql-server (--configure):
old mysql-server package postinst maintainer script subprocess failed with exit status 1

The MySQL error log contains:

[ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
[ERROR] [MY-013236] [Server] The designated data directory /home/mysql/ is unusable.
[ERROR] [MY-010119] [Server] Aborting

Running dpkg --audit reports:

The following packages are only half configured:
mysql-server

However, MySQL itself starts successfully and remains operational.

Root cause

The Ubuntu post-installation script:

/var/lib/dpkg/info/mysql-server.postinst

uses the following hardcoded directory:

mysql_statedir=/var/lib/mysql

It then checks whether that directory is empty:

if [ ! "$(ls -A "${mysql_statedir}" -I "lost+found")" ] && [ -d "${mysql_filesdir}" ]; then

Since /var/lib/mysql is empty, the script attempts to initialize MySQL:

mysqld --initialize-insecure --user=mysql --init-file="$initfile"

However, MySQL is configured to use /home/mysql, which already contains an initialized database.

The initialization therefore fails.

Expected behavior

The MySQL package upgrade should detect the existing database and complete without attempting to initialize it again.

Possible Solution

Confirmed workaround

The issue was successfully resolved by modifying:

/var/lib/dpkg/info/mysql-server.postinst

Changing:

mysql_statedir=/var/lib/mysql

To:

mysql_statedir=/home/mysql

After applying this change, the package configuration completed successfully without modifying or moving the existing databases.

Suggested permanent fix

CloudPanel could provide an upgrade-safe solution to ensure compatibility between its custom MySQL data directory and Ubuntu's package maintenance scripts.

Possible approaches:

  • Ensure that the directory checked by the Ubuntu post-installation script matches the actual MySQL data directory.
  • Investigate whether Ubuntu's MySQL packaging can support custom data directories automatically.
  • Introduce a persistent compatibility mechanism that survives future MySQL package upgrades.

The current workaround modifies a dpkg-managed script, which may be overwritten during future package updates.

A permanent solution would prevent the problem from recurring during MySQL security updates.

Additional Context

The issue was reproduced and resolved on November 3, 2026.

The MySQL service remained operational despite the package configuration failure:

Active: active (running)
Status: "Server is operational"
Version: 8.4.11-0ubuntu0.26.04.1

Directory permissions and state before applying the workaround:

drwx------ mysql mysql /home/mysql
drwx------ mysql mysql /var/lib/mysql

/var/lib/mysql was empty, while /home/mysql contained the existing databases.

No database deletion, reinitialization, or data migration was required to resolve the issue.

The workaround was validated successfully, but it has not yet been tested against subsequent MySQL package upgrades.

Activity

  1. kentsor commented on Nov 13, 2026

    @kentsor

    Same issue here, with a worse outcome: MySQL stayed stopped and every site on the server was down for about 3 hours.

    CloudPanel 2.5.4-5+clp-resolute (CLI 6.0.8), Ubuntu 26.04.1 LTS, installed with DB_ENGINE=MYSQL_8.4, unattended-upgrades on (Ubuntu default).
    The upgrade 8.4.11-0ubuntu0.26.04.1 to 8.4.13-0ubuntu0.26.04.2 was installed by unattended-upgrades at night, unattended.
    In our case /var/lib/mysql did not exist before the upgrade. stat shows that the new mysql-server package created it, empty, during the unpack.
    The postinst runs invoke stop before the failing --initialize step and exits before deb-systemd-invoke start, so MySQL was left stopped: "Server shutdown complete", then the same MY-010457 / MY-013236 errors.
    We recovered with systemctl start mysql, which upgraded the data dictionary 80411 to 80413 by itself. mysql-server is still half configured, so the MySQL packages are on apt-mark hold and the unattended-upgrades timer is paused. Any retry of the configure step would stop MySQL again.
    So on a stock CloudPanel 2.5.4 + Ubuntu 26.04 + MySQL 8.4 install, every MySQL security update can take the server's sites offline until someone notices. Could the maintainers confirm the supported fix (for example a symlink /var/lib/mysql to the datadir set by the installer, or MySQL excluded from unattended-upgrades) and the safe way to complete the pending configure?

  2. kentsor commented on Nov 13, 2026

    @kentsor

    We did the symlink, it worked

  3. gibbz-one commented on Nov 19, 2026

    @gibbz-one

    Same issue. Is there an "official" solution for this problem?

  4. gibbz-one commented on Nov 23, 2026

    @gibbz-one

    I tried placing an empty file in the datadir so that the post-installation script would consider the folder to be non-empty:

    touch /var/lib/mysql/.datadir-is-home-mysql
    chown mysql:mysql /var/lib/mysql/.datadir-is-home-mysql
    

    For now, it’s working correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions