Ubuntu 16.04 mysql update fails
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.
Anyway I was updating my packages today and got this error:
dpkg error processing package mysql-server-5.7 (--configure)
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.
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:
sudo systemctl stop mysql
Then you need to remove the MySQL packages with:
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7
Once done make sure the MySQL directories
sudo rm -rf /etc/mysql /var/lib/mysql
Now run apt-get cleanup commands
sudo apt-get autoremove sudo apt-get autoclean
Reboot your server and run apt update and reinstall MySQL with
sudo apt update sudo apt-get install mysql-server mysql-client
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.