On a Ubuntu 20.04 (Focal) system, MySQL should be upgraded from 5.7 to 8.0, using the MySQL community packages from the MySQL repositories.
Note: Read here how to install a MySQL Community Server 5.7 on Ubuntu 20.04.
But a "simple" task turned out to be a weird head-scratcher.
Oracle has prepared a deb package to configure the MySQL community repositories on Debian and Ubuntu systems. The package not only contains the correct APT sources configuration but also the needed GPG public key.
So let's download and install the mysql-apt-config package:
root@mysqlserver:~# wget https://dev.mysql.com/get/mysql-apt-config_0.8.28-1_all.deb
root@mysqlserver:~# dpkg -i mysql-apt-config_0.8.28-1_all.deb
(Reading database ... 111489 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.28-1_all.deb ...
Unpacking mysql-apt-config (0.8.28-1) over (0.8.24-1) ...
Setting up mysql-apt-config (0.8.28-1) ...
In a ncurses menu, the wanted MySQL server and version can be chosen. With current mysql-apt-config packages, the only choice should be version 8.0. Once MySQL Community Server 8.0 was chosen and confirmed with "Ok", the ncurses dialog disappears again and the package installation and configuration is completed.
Time to do the upgrade by installing the MySQL community packages:
root@mysqlserver:~# apt-get install mysql-community-server mysql-community-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mysql-community-client : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.12 is to be installed
Depends: libssl3 (>= 3.0.0) but it is not installable
Depends: libstdc++6 (>= 11) but 10.5.0-1ubuntu1~20.04 is to be installed
Depends: mysql-community-client-core (= 8.0.35-1ubuntu23.04) but it is not going to be installed
mysql-community-server : Depends: mysql-community-server-core (= 8.0.35-1ubuntu23.04) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
What now? Why wouldn't this work? A dependency on libc6 in version 2.34? Comparing this with the currently installed version:
root@mysqlserver:~# dpkg -l|grep libc6
ii libc6:amd64 2.31-0ubuntu9.12 amd64 GNU C Library: Shared libraries
Why would a package for focal require a newer version?
And this question led me to verify the actual APT source definition of the MySQL repositories:
root@mysqlserver:~# cat /etc/apt/sources.list.d/mysql.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/ubuntu/ lunar mysql-apt-config
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/ubuntu/ lunar mysql-8.0
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/ubuntu/ lunar mysql-tools
#deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/ubuntu/ lunar mysql-tools-preview
deb-src [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/ubuntu/ lunar mysql-8.0
What the... ?! The MySQL repositories were all configured with the "lunar" distribution release, instead of focal, what this machine is using.
Maybe the lunar release somehow got hard-coded into the mysql-apt-config package?
After replacing the wrongly configured "lunar" entries with "focal", the installation and therefore MySQL upgrade worked:
root@mysqlserver:~# sed -i "s/lunar/focal/g" /etc/apt/sources.list.d/mysql.list
root@mysqlserver:~# apt-get update
root@mysqlserver:~# apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-community-client-core
mysql-community-client-plugins mysql-community-server-core
The following packages will be upgraded:
libmysqlclient21 mysql-client mysql-community-client mysql-community-server mysql-server
5 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 44.1 MB of archives.
After this operation, 37.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
[...]
MySQL community server 8.0 was running smoothly after this.
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder