Score:-1

Can't remove mysql completely

cn flag

I tried many times to completely remove MySQL from my system without success. I get these errors:

Photo error 1

Photo error 2

I also tried other commands without success. What should I do?

Here is the output of apt list --installed | grep mysql:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

default-libmysqlclient-dev/focal,now 1.0.5ubuntu2 amd64 [installed]
libmysqlclient-dev/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 amd64 [installed]
libmysqlclient21/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 amd64 [installed]
libmysqlclient21/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 i386 [installed]
libpocodatamysql62/focal,now 1.9.2-3ubuntu3 amd64 [installed]
mysql-client-8.0/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 amd64 [installed]
mysql-client-core-8.0/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 amd64 [installed]
mysql-common/focal,focal,now 5.8+1.0.5ubuntu2 all [installed]
mysql-server-8.0/now 8.0.27-0ubuntu0.20.04.1 amd64 [installed,upgradable to: 8.0.28-0ubuntu0.20.04.3]
mysql-server-core-8.0/focal-updates,focal-security,now 8.0.28-0ubuntu0.20.04.3 amd64 [installed]

Here I am inside /var/lib/dpkg/info/ and I searched for "mysql" and I see these files:

enter image description here

Should I delete them or is it a bad idea? If I delete them, will I be able to uninstall everything related to MySQL?

Using this command:

sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

I get this error:

enter image description here

Someone avatar
my flag
Please edit to post the output of `apt list --installed | grep mysql`. Please post the full error message and format it as code instead of adding images.
Score:1
my flag

To completely remove a package, we can use the apt purge command with arguments such as --autoremove to clear off the dependencies along with their parent packages. In your specific case, I don't think apt purge will work as dpkg is throwing errors with the pre-installation script. It seems like you have manually removed some files or directories.

  • Use the dpkg command with the -P argument to forcefully purge the package.

For forcefully purging the package.

  1. Since removing packages can be destructive, print the list of the package that will be removed:

    dpkg -l | awk  '{print $2}' | grep -i mysql | grep -v lib
    

    Check if any important package is being removed. If everything seems fine, proceed to step 2.

  2. Purge the packages:

    sudo dpkg -P  --force-all $(dpkg -l | awk  '{print $2}' | grep -i mysql | grep -v lib)
    

This should completely remove MySQL. Then run a force install:

sudo apt -f install
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.