I rebooted an Ubuntu 12.04 server after upgrading the kernel and MySQL. However, I found that the new MySQL would not start. When I tried:
sudo service start mysql
I got:
start: job failed to start
There were no errors appearing in the /var/log/mysql/error.log and so there was no information to help debug it. I found this post and tried every single one of the solutions. When I removed mysql-server-5.5 using:
apt-get –purge remove mysql-server
rm /etc/mysql/ -R
I found the when I reinstalled mysql-server the installation would fail saying:
Unable to set password for the MySQL “root” user 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.
I then got stuck because I could no longer remove MySQL because it was only partially installed. Every time I tried to remove it, it would ask me to put in a new root password which I obviously could not do. The solution is to use dpkg to purge the partially installed package:
dpkg –purge mysql-server-5.5
Then I tried reinstalling again and got:
Can’t find file: ‘./mysql/host.frm’ (errno: 13)
Basically, the solution to these problems is a complete purge of MySQL and removing ALL of it and start again. I found what mysql related packages I have install by running:
dpkg –get-selections | grep mysql
and found I had:
libdbd-mysql-perl
libmysqlclient18
mysql-client-5.5
mysql-client-core-5.5
mysql-common
mysql-server
mysql-server-5.5
mysql-server-core-5.5
mysqltuner
php5-mysql
I removed all them!
apt-get –purge remove mysql-server
apt-get –purge remove mysql-client
apt-get –purge remove mysql-common
…… etc …. etc…
Then cleared the apt-get cache and removed the mysql config and data directories (I have a backup of the data from the night before.) Note – these commands will remove all your old MySQL data, so don’t run them if you don’t have a backup or you don’t care about the data.
apt-get autoremove
apt-get autoclean
rm /etc/mysql/ -R
rm /var/lib/mysql/ -R
Then reinstalling mysql-server and the other packages.
apt-get install mysql-server
etc….
What a massive waste of time! Oh well – I hope this post helps someone else out of this pickle.