MySQL 8.0 Upgrade Errors on Ubuntu 20.04

Share This:

MySQL 8.0 Ubuntu 20.04 Upgrade Errors

I recently upgraded my server from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS. In a previous post, I outlined the steps for upgrading NGINX on Ubuntu 20.04 coming from Ubuntu 18.04. Now I ran into errors trying to perform an update for MySQL 8.0 on Ubuntu 20.04. Looking at the MySQL 8.0 bug list, I could see a number of people having similar issues as me.

Originally, I had issues with my my.cnf file. At some point, I must have removed the symlinks and used static config files. If you run into issues, look at your logs /var/log/mysql/error.log, /var/log/syslog, and /var/log/apt/term.log for clues.

Some of the errors I saw were:

dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.

[ERROR] [Server] Plugin mysqlx reported: ‘Setup of socket: ‘/var/run/mysqld/mysqlx.sock’ failed, can’t create lock file /var/run/mysqld/mysqlx.sock.lock’

Since I don’t use mysqlx, I added mysqlx = 0 under [mysqld] in my mysqld.cnf.

I also saw depreciation errors about expire_logs_days, so I commented that out in my config as well.

Someone in a thread mentioned setting thread_stack = 256K if you had it set lower, although that didn’t make a difference for me.

You should have two config symlinks. If you’ve ever changed any of these, it might throw errors:
/etc/mysql/my.cnf -> /etc/alternatives/my.cnf
/etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf

Some mysql.cnf commands have been depreciated as well. Check the errors logs and try tuning your mysql.conf file based on MySQL 8.0.

Check AppArmor

My final issue appeared in /var/log/syslog. The error that APT was showing was installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1. The upgrade would appear to hang and timeout but MySQL was actually running. During the MySQL upgrade, some errors were logged referencing AppArmor and MySQL that started with apparmor=”DENIED” operation=”open” profile=”/usr/sbin/mysqld”.

While running sudo apparmor_status, I could see /usr/sbin/mysqld was in enforced mode.

Running these commands will disable AppArmor for mysqld:

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld

You can verify this by running sudo apparmor_status again. Once AppArmor is disabled you can try upgrading MySQL again.

Final Thoughts

After making this change, APT was able to successfully install the update for me. If you still see errors, feel free to post them in the comments below. Most of this post was from memory of troubleshooting this for a day.

Share This:


One Response

  1. Bhupendra Kumar February 10, 2021

Leave a Reply