Cannot install mysql server 5.5 on ubuntu 14.04

I have tried many ways to install mysql-server. I first tried installing by executing

sudo apt-get install mysql-client-5.5 mysql-server mysql-server-core-5.5

I was asked for root password, and that I did. But the install was not complete some unmet dependency came up. Very similar to in this question. I have then tried different combinations and unmet dependency issue went away but I started getting this

Preparing to unpack .../mysql-server_5.5.43-0ubuntu0.14.04.1_all.deb    
Unpacking mysql-server (5.5.43-0ubuntu0.14.04.1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.5_5.5.43-
0ubuntu0.14.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have already tried removing and purging dependencies through various methods like in this question 2. I have also tried doing that via Aptitude and tried installing mysql-server again, but with no success. Please help me out!


Solution 1:

dpkg --get-selections | grep "mysql"(It list all installed mysql in your system)

If still mysql installed In Your System remove it first by using following commands.

    sudo apt-get --purge remove mysql
    sudo apt-get autoremove mysql
    sudo apt-get autoclean mysql

check for /etc/mysql/my.cnf and /var/lib/mysql files. If these files still exist then remove them by using

  sudo rm -rf /etc/mysql/
  sudo rm -rf /var/lib/mysql/  

Above two commands completely removes your MySQL data directory and configuration file.please sure before removing it.

Once update your system:

sudo apt-get update 

After update install MySQL server

sudo apt-get install mysql-client mysql-server

Solution 2:

Remove the cached deb file:

sudo rm /var/cache/apt/archives/mysql-server-5.5_5.5.43-0ubuntu0.14.04.1_amd64.deb

and try it again:

sudo apt-get install -f
sudo apt-get install mysql-client mysql-server

Alternatively, install version 5.6:

sudo apt-get remove mysql-server mysql-client
sudo apt-get install mysql-server-5.6 mysql-client-5.6