6

I am getting the following error when I remove, autoremove, install, upgrade etc.. via terminal and also software updater.

The sudo apt-get autoremove result is given below. The error says dpkg error processing the mysql-server.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
No apport report written because the error message indicates its a followup error from a previous failure.
                      dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
 dpkg: dependency problems prevent configuration of mysql-server:
  mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

 dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

referred this link also : link

Help to reconfigure the mysql.

also tried dpkg reconfiguration. (Consider before duplicating the question)

Edit 1: My ubuntu version is 14.04 LTS

Edit 2: sudo apt-get upgrade result:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

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.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo dpkg --configure -a result:

Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server

sudo apt-get remove mysql-server result:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-server
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 131 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 209845 files and directories currently installed.)
Removing mysql-server (5.5.49-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
 start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)
anand mbs
  • 431
  • Try sudo dpkg --configure -a. – Jos Jun 21 '16 at 12:31
  • also tried it up @Jos – anand mbs Jun 22 '16 at 03:00
  • @anandmbs, same answer here should work try it https://askubuntu.com/questions/687319/how-does-apt-get-purge-work-why-it-couldnt-remove-broken-package-in-one-pass – user.dz Jun 30 '16 at 17:55
  • But this question is not giving me the desired output. it depends on some other package. different from sql – anand mbs Jul 01 '16 at 03:20
  • @Sneetsher you can see the differences in the errors generated which is different from them. So that cannot be the solution – anand mbs Jul 01 '16 at 03:28
  • 1
    You have subprocess installed post-installation script returned error exit status 1 , post-installation script is *.postinst file. In your case /var/lib/dpkg/info/mysql-server-5.5.postinst which run on configure step of the package installation. When it does fail, you are locked in, because even remove operation will try complete the stopped configure step tehn remove package. So open /var/lib/dpkg/info/mysql-server-5.5.postinst & manually edit it and add set -e on 2nd line to ignore any error (basically invoke-rc.d/init fails to restart the mysql service). restart it manually after. – user.dz Jul 01 '16 at 03:42

4 Answers4

10

This worked for me

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

then after that I installed mysql again with

sudo apt-get install mysql-server 

and now its working fine.

3

None of the apt methods worked for me, try this:

Find locking process

$ ps -eaf
root      7316     1  0 00:19 ?        00:00:00 /usr/bin/dpkg --status-fd 35 --configure --pending
root      7808  7316  0 00:19 ?        00:00:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-se
root      7817  7808  0 00:19 ?        00:00:00 /bin/bash /var/lib/dpkg/info/mysql-server-5.7.postinst configure
mysql     7973  7817  0 00:20 ?        00:00:00 mysqld --user=mysql --init-file=/var/lib/mysql-files/tmp.iNyY06ty0K --so

Kill it

do sudo kill -9 7973, basically the mysql one.

Now purge

sudo apt-get purge mysql-server-5.7 # Or whatever you are trying to purge.
1

This error could also happens if the port (3306) is being used by another app. In my case, I had a docker container running mysql which was using the 3306 port, hence my local mysql installation fialed to configure.

$ sudo netstat -nltp | grep LISTEN | grep 3306
$ sudo netstat -nltp | grep LISTEN | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      1017033/docker-prox

sudo apt purge --auto-remove mysql* sudo rm -r /etc/mysql sudo rm -r /var/lib/mysql*

sudo apt install mysql-client-8.0 mysql-server-8.0 --fix-broken -y

Zstack
  • 201
0

I came across the yes Unix binary, which is incredibly stupid: it just endlessly types y (try it, you can just run yes in your terminal)

so the following just works (I used this in a dockerfile)

yes | apt-get install mysql-community-server
Nadir
  • 226