23

I just installed MySQL-server and all of its dependencies, among other necessities. But when it went to configure mysql-server it failed to do so, and spit out an error. Which error is not relevant here as I managed to locate the problem as a dependency issue between mysql-server and mysql-common. Mysql-common needs to be removed.

But when I go to

apt-get purge remove mysql-common 

It automatically wants to remove everything in association with it as well, including all mysql dependencies, even apache2 and php5..

So what argument needs to be added to apt-get command to uninstall ONLY ONE package, yet leave all others intact.

svick
  • 142
insomnia
  • 415

2 Answers2

31

apt-get won't let you do that, since it's a potentially dangerous step for a package management system to allow.

As long as you are aware that there may be consequences, use dpkg with the --remove option to do it. For example:

sudo dpkg --remove mysql-common

Note: On my 12.04 system with apache2, php5, mysql-server installed separately, using apt-get to remove mysql-common DOES NOT want to remove apache2 or php5.

From insomnia's comment: If you need to override the dependency system's decision you can (with great care and making sure you know what you are doing) use an additional --force-depends.

sudo dpkg --remove --force-depends mysql-common
guntbert
  • 13,134
ish
  • 139,926
  • Okay thanks. Many others claimed it worked. I mean a lot of people. But yeah that happens on ubuntu. But im actually on debian. But i asked here cuz i am a user here, and they are very similar and the package system is the same.. thanks bud. – insomnia Aug 09 '12 at 21:03
  • don't worry man. I'm not gonna leave you hanging. I always accept. People just usually ignore it after i accept and there is still an issue. But I just tried it and it wouldnt let me. Is there a force command? – insomnia Aug 09 '12 at 21:15
  • Sorry, that's right - I think you have to wait a certain amount of time before you can do it - 15 mins, I think? Please try again whenever you have a chance, no hurry. Also, I just noticed that you mentioned you are using Debian -- note that questions involving Debian are off-topic, and are often closed as such. Please consider asking on unix.stackexchange.com for something Debian-specific in the future :) – ish Aug 09 '12 at 21:20
  • Yeah, I figured as such.. main reason why I didnt really mention it until I needed. I mean their package managers are the same, Ubuntu is just suped up debian. but alright. the 15 minute thing doesnt work though, cuz I tried way longer than 15 minutes after. But cant I type something similar to "dpkg -f --remove mysql-common"? – insomnia Aug 09 '12 at 21:31
  • If plain --remove gives you a warning and aborts, sure, you can force it with -f. BTW, --remove is the same as -r. – ish Aug 09 '12 at 21:35
  • okay. the -r should work then. Because when I try "dpkg -f --remove" it wont work as a correct arguement. so maybe "dpkg -r --force" will. Thanks man I appreciate the help. – insomnia Aug 09 '12 at 21:46
  • Oh for reference for others in the future. I managed to get it to work by typing "dpkg -r --force-depends mysql-commons". So if you keep getting an error about dependencies, preventing it from removing the file, because of its dependencies, make sure you add "--force-depends" then it will leave the dependencies untouched. But as izx stated, be careful with this as you could do more harm than good. Make sure you ABSOLUTELY know what you are doing here.. Good luck folks. – insomnia Aug 09 '12 at 22:48
0

If anyone would like to know there 2014 debian command its:

dpkg --force-all -r name_of_package

Its changed a bit

There is alot of --force- arguments so for sake of depency better check them by:

dpkg --force-help
  • 1
    --force-all is definitely not safe, why not suggest --force-depends AND provide an appropriate warning too? – guntbert Sep 13 '14 at 16:00
  • 1
    It's never safe to delete package that is needed for other packages without uninstalling the other one. --force-all is just quick and dirty approach – Michal Sapsa Sep 13 '14 at 16:35