Linux, Programming, Scripting

Howto: Fix MySQL Server dependency problems on Ubuntu LTS

Have you encountered this error?

An error occurred while setting the password for the MySQL administrative user.
This may have happened because the account already has a password, or because of a
communication problem with the MySQL server.

Or maybe seen this?

Errors were encountered while processing:
mysql-server-5.5
mysql-server

Or this?


dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured

This is a total bastard of a problem. Here’s what worked for me:

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-5.5
sudo dpkg --purge mysql*
sudo rm -rf /etc/mysql
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get install mysql-server
sudo reboot

Purge everything that even looks like mysql. Remove the /etc/mysql directory manually, because mysql-common is going to try to hide there. Fix any broken dependencies and reconfigure any broken packages. You may get the same error again when trying to reinstall mysql-server. I threw up my hands and went to bed at that point, woke up this morning deciding to finally learn PostgreSQL, got this error:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

and believe it or not, a reboot fixed the problem for me. mysqld started on reboot. I rubbed my eyes, and wrote this post in case it ever bloody well happens again.

Tagged , , , ,

Leave a Reply