Improve MariaDB version check and upgrade logic.