Bug #119783 mysql-common postinst fails when /etc/mysql/my.cnf.fallback is missing

Submitted: 26 Jan 19:12
Reporter: Antonios Tsianakas Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Package Repos Severity:S3 (Non-critical)
Version:8.4.8 OS:Ubuntu
Assigned to: CPU Architecture:x86

[26 Jan 19:12] Antonios Tsianakas
Description:
The mysql-common package postinst script unconditionally attempts to register 
/etc/mysql/my.cnf.fallback as an alternative without checking if the file exists, 
causing installation failures when the file is not present or has been removed.

AFFECTED VERSIONS:
mysql-common package from apt.mysql.com repository. Tested with Ubuntu Noble 24.04

The postinst script in mysql-common contains the following code:

if [ "$1" = "configure" ]; then
    # Low priority fallback for client use when no server is installed.
    update-alternatives --install /etc/mysql/my.cnf my.cnf /etc/mysql/my.cnf.fallback 100
fi

This code does not verify that /etc/mysql/my.cnf.fallback exists before attempting 
to register it as an alternative. If the file is missing (e.g., manually removed, 
incomplete upgrade, or system inconsistency), the installation fails with:

update-alternatives: error: alternative path /etc/mysql/my.cnf.fallback doesn't exist
dpkg: error processing package mysql-common (--configure):
 installed mysql-common package post-installation script subprocess returned error exit status 2

How to repeat:
1. Install mysql-common package
2. Remove /etc/mysql/my.cnf.fallback
3. Attempt to upgrade or reinstall eg. apt install --reinstall mysql-common

Suggested fix:
The official Ubuntu MySQL packages handle this correctly by checking for 
file existence:

if [ "$1" = "configure" ] && [ -f /etc/mysql/my.cnf.fallback ]; then
    # Low priority fallback for client use when no server is installed.
    update-alternatives --install /etc/mysql/my.cnf my.cnf /etc/mysql/my.cnf.fallback 100
fi

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.047 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.