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:
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!

  • Remove the cached archive: sudo rm /var/cache/apt/archives/mysql-server-5.5_5.5.43- 0ubuntu0.14.04.1_amd64.deb
    – A.B.
    Jun 29, 2015 at 17:56
  • sudo rm /var/lib/mysql/debian-5.6.flag Jun 29, 2015 at 19:25
  • I did as you said and I remooved the debian .flag file too. It installed successfully but gave error at setting root password. Running mysql gave this error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2). So I gave up and installed 5.6 mysql server and client via Aptitude. Thanks anyways Jun 29, 2015 at 19:38
  • Than I have an answer for you :)
    – A.B.
    Jun 29, 2015 at 20:21

2 Answers 2


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
  • Installing new version of config file /etc/init.d/mysql Installing new version of config file /etc/apparmor.d/usr.sbin.mysqld start: Job failed to start invoke-rc.d: initscript mysql, action "start" failed dpkg: error processing package mysql-server-5.6 (--configure): subprocess installed post-installation script returned error exit status 1 Setting up libhtml-template-perl (2.95-1) Setting up mysql-common-5.6 (5.6.27-0ubuntu0.14.04.1) Processing triggers for ureadahead Errors were encountered while processing:mysql-server-5.6 E: Sub-process /usr/bin/dpkg returned an error code (1)
    – user269867
    Dec 21, 2015 at 22:02
  • Tried all the steps , removed all the mysql related packages, still i get ": dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: mysql-server-5.6 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)
    – Sushivam
    Oct 27, 2016 at 10:59

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
  • Just a note for any future people with the same problem: I tried installing it as root, but wouldn't succeed. But as a normal user and sudo install all the packages, it worked. Maybe this will help anybody in the future...
    – Mathlight
    Sep 27, 2016 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.