15

I have a Dell Mini9 running Ubuntu 8.10. One day I had the bright idea to see if I could install a LAMP stack. I had trouble installing MySQL 5.0. I don't recall the error, but ever since all attempts to run update-manager, synaptic, or apt-get fails with an error about mysql-server-5.0: "Package is in a very bad inconsistent state".

I've tried apt-get remove mysql-server-5.0 and also install but with no luck. Both fail with the same error below. How can I fix this?

$ sudo apt-get remove mysql-server-5.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dhcdbd libisc32
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server-5.0
0 upgraded, 0 newly installed, 1 to remove and 164 not upgraded.
1 not fully installed or removed.
After this operation, 85.4MB disk space will be freed.
Do you want to continue [Y/n]? 
dpkg: error processing mysql-server-5.0 (--remove):
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.
Errors were encountered while processing:
 mysql-server-5.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
1
  • Consider using <pre> for screen output where syntax highlighting is not needed.
    – John Oxley
    Aug 13, 2009 at 3:57

7 Answers 7

20

None of the other answers worked for me on Maverick.

In my case, I found this worked:

sudo rm /var/lib/dpkg/info/flashplugin-nonfree.prerm

sudo dpkg --remove --force-remove-reinstreq flashplugin-nonfree

(replacing "flashplugin-nonfree" with the name of the broken package, and replacing "prerm" with the type of script that failed - in my case it was "postrm", the post-removal script.)

And they say Ubuntu is easy to use!! grumble grumble

2
  • --purge is better to drop broken deps
    – stepancheg
    Mar 5, 2011 at 20:56
  • 1
    I've been searching for hours for a solution to a similar problem, and this is the only one that worked. Thankyou.
    – LukeGT
    May 19, 2012 at 8:35
6

I had the exact same issue with a mysql install. You need to purge the packge. Simply removing a package does not remove the config files that came with it.

Also, I'm going to refer to mysql-server-5.0, but realize that there's a wrapper package mysql-server that always points to the latest version. i.e. if you ask to install mysql-server, apt-get should tell you that it depends on mysql-server-5.0 and install both. If you have the mysql-server package on the system, you should make sure that's gone too before you attempt to reinstall.

  • Make sure the mysql server (mysqld) isn't running. If it is, bring it down:

    sudo /etc/init.d/mysqld stop

  • Check if any packages depend on mysql-server-5.0:

    sudo apt-cache rdepends mysql-server-5.0

    If they do, you'll need to use the --force option to uninstall.

  • Purge the package (include the --force option, depending on #2)

    sudo apt-get --purge remove --force mysql-server-5.0

  • Make sure the installer files are also cleared by running

    sudo apt-get autoclean
    sudo apt-get autoremove

  • Install the server package again

    sudo apt-get install mysql-server-5.0

This should hopefully fix your problem. However, the package might still be broken, if you made any changes to files that came from the mysql-common package.

mysql-common is the base package used by both client and server components. If things aren't working still, try re-installing this package. There will definitely be packages that depend on this; check using #2 above. Purge mysql-server before reinstalling mysql-common. Also, do not forget to reinstall mysql-common, else your system will be very broken.

1

You might want to give aptitude a try, which has better handling of dependencies:

sudo aptitude remove mysql-server-5.0
2
  • The error here is dpkg's, so I don't think aptitude would necessarily fare any better. Don't get me wrong, I'm all for aptitude over apt-get, but at the end of the day, they both hand the real nitty-gritty over to dpkg (which you'll be happy to hear was originally implemented in Perl).
    – Telemachus
    Aug 13, 2009 at 8:35
  • ;-) I just thought it might be worth a try.
    – innaM
    Aug 13, 2009 at 9:46
1

I had this problem with mailman. Deleted /etc/init.d/mailman with

rm /etc/init.d/mailman

fixed it :)

0

Try

sudo dpkg -i reconfigure mysql-server-5.0
sudo apt-get remove --force mysql-server-5.0

If its another package that is broken, try apt-get remove --force that package as well.

0

The dpkg error that you have there suggests that the problem occurs when dpkg is trying to actually remove the package. (At the end of the day, apt-get and Synaptic and the like hand off the actual work to dpkg.)

Have you tried doing exactly what the message says and re-installing first?

apt-get install --reinstall mysql-server-5.0

As silly as it might sound, if dpkg is choking during the removal process (because some file it's supposed to remove has gone missing in the interim) then reinstalling and then removing can sometimes help. Make sure that mysql is not running before you try to install it or remove it, as nagul suggests.

0

dpkg -r --force-remove-reinstreq <package> removes a package without checking if it requires reinstallation.

After that you should be able to reinstall the package with your preferred package manager.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .