Skip to content
Snippets Groups Projects
Commit 4cbbcb7e authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Enable automatic datadir move also on upgrades from MySQL.com packages

Seems the MySQL.com packages don't set a 'debian-*.flag' file in the data
directory, thus breaking the downgrade/cross-grade detection. Add a new
section to assume MySQL 8.0 if no flag exists but file 'undo_001' exits.
parent 3c71bec9
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,16 @@ then
fi
# If there is no debian-*.flag, and no version was detected, but a file that
# indicated MySQL 8.0 is found, assume so and trigger data directory moval.
if [ -z "$found_version" ] &&
[ -z "$(find $mysql_datadir/debian-*.flag 2> /dev/null)" ] &&
[ -f "$mysql_datadir/undo_001" ]
then
echo "$mysql_datadir: no server version flag found, assuming MySQL 8.0 data encountered"
downgrade_detected=true
found_version="previous" # Just use dummy name as we don't know real version
fi
# Don't abort dpkg if downgrade is detected (as was done previously).
# Instead simply move the old datadir and create a new for this_version.
......@@ -133,8 +143,8 @@ then
echo "Please manually export/import your data (e.g. with mysqldump) if needed." 1>&2
mv -f "$mysql_datadir" "$mysql_datadir-$found_version"
# Also move away the old debian.cnf file that included credentials that are
# no longer valid
mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version"
# no longer valid. If none existed, ignore error and let dpkg continue.
mv -f /etc/mysql/debian.cnf "/etc/mysql/debian.cnf-$found_version" || true
fi
# to be sure
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment