Often after doing dist-upgrade
on Ubuntu using a command,
sudo apt-get dist-upgrade
MySQL server fails to start throwing an error message,
sudo service mysql start
error: start: Job failed to start
Here is a simple solution to above problem.
Create a backup of your existing MySQL
sudo cp -r /var/lib/mysql ~/mysql-backup
Remove existing MySQL package and related files
sudo apt-get purge mysql-server-5.1 mysql-common
Remove configuration files if any
remove files from /etc/mysql/
sudo rm /etc/mysql/ -R
Restore and fix permissions
After a purge, you can restore back your backup files to /var/lib/mysql
if they does not exist.
sudo mkdir /var/lib/mysql sudo cp -r ~/mysql-backup/* /var/lib/mysql
and fix the permissions.
sudo chown root:root /var/lib/mysql/ -R
Reinstall MySQL
Now reinstall MySQL package.
sudo apt-get install mysql-server
This should fix the problem. Verify it using,
sudo service mysql start