We all been there when an update fails but with an LTS server version you would think this would be something the Ubuntu team would fix quickly.

Problem:

Anyway I was updating my packages today and got this error:

Now apt seems to be broken after this. (boo hoo and aarrgghh) after a quick google search I found no nice solution my only option was to reinstall, but how do I do that when I can’t remove MySQL anymore.

Solution:

The good news is this can be fixed but not in a nice way so first thing is to make a backup of your database see http://www.shaunfreeman.name/a-quick-mysql-backup-and-restore/ on how to do this. When done you need to stop the current MySQL service with:

Then you need to remove the MySQL packages with:

Once done make sure the MySQL directories

Now run apt-get cleanup commands

Reboot your server and run apt update and reinstall MySQL with

Once done restore your databases. You will also need to rest all passwords on all database user accounts as this seem to clear them.

I also didn’t recommend any saving of a customised ‘my.cnf’ as this seems to be the culprit that causing this error.

Anyway hope this helps and the Ubuntu team fix this really annoying error. If anyone has any suggestions on a better fix please let me know.

Thanks and happy coding.