simhumileco
simhumileco

Reputation: 34515

How to forcefully remove MySQL and MariaDB from Ubuntu 16.04, without `apt-get` and `dpkg`?

By wrong uninstalling MariaDB, I've lost working instance of MySQL and MariaDB in my Ubuntu 16.04 system...

I've broken the dependencies so much, that I can not uninstall or install MySQL or MariaDB, using apt-get, or dpkg...

All the following commands failed:

apt-get [install -f] [update] [remove] [purge] [autorove] [clean] [check]

and options with dpkg such as:

dpkg --remove --force-remove-reinstreq mysql

also don't help me.

Manually downloading the package and attempting to install from a local file did not help.

For each installation, uninstallation or other attempt, I get almost the same result:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 mariadb-client : Depends: mariadb-client-10.0 (>= 10.0.34-0ubuntu0.16.04.1) but it is not installed
 mariadb-server-10.0 : PreDepends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not installed
                       Depends: mariadb-client-10.0 (>= 10.0.34-0ubuntu0.16.04.1) but it is not installed
                       Breaks: mysql-server
 mariadb-server-core-10.0 : Depends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not installed
 mysql-server : Depends: mysql-community-server (= 5.7.22-1ubuntu16.04) but it is not installed
E: Unmet dependencies. Try using -f.

Is there any different way to permanently remove any traces and remnants of MySQL and MariaDB from the operating system, so that I can reinstall MySQL itself?

I need to working with MySQL, but I can't reinstall the operating system.

Please help me.

Upvotes: 0

Views: 13730

Answers (2)

Yuri Lachin
Yuri Lachin

Reputation: 1500

It is probably better to address the question to serverfault.com.

Run:

dpkg --audit

to find what is broken.

Then run:

dpkg --list|grep -i mysql

and

dpkg --list|grep -i mariadb

Look at the first (status) column and, optionally, inspect detailed status for some of packages with:

dpkg-info -s <name-of-package>

Then you can try to remove found mysql/mariadb related packages with

dpkg -remove --force-remove-reinstreq <package-list>

As a way around you can always run mysq in docker container without mysql being installed

Upvotes: 2

simhumileco
simhumileco

Reputation: 34515

God exists! :D

The problem was solved by entering:

sudo apt-get -f install

without any other parameters

and later displaying all packages via:

sudo dpkg -l | grep mariadb
sudo dpkg -l | grep mysql

and removing problematic packages in the right order:

sudo apt-get --purge autoremove package_name

After the complete removal of all problematic packages, I could re-install MySQL without any problems...

Thank you @YuriLachin for your help.

Upvotes: 3

Related Questions