Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)
share|improve this question
    
Consider using <pre> for screen output where syntax highlighting is not needed. –  John Oxley Aug 13 '09 at 3:57
    
Thanks for pointing that out. Now it looks better. –  spoulson Aug 13 '09 at 13:55
add comment

7 Answers

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

share|improve this answer
    
--purge is better to drop broken deps –  stepancheg Mar 5 '11 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 '12 at 8:35
add comment

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.

share|improve this answer
add comment

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

sudo aptitude remove mysql-server-5.0
share|improve this answer
    
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 '09 at 8:35
    
;-) I just thought it might be worth a try. –  innaM Aug 13 '09 at 9:46
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

rm /etc/init.d/mailman

fixed it :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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