How do I remove only one specific package with apt-get?

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.


Solution 1:

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