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

我是研究僧i 提交于 2020-01-26 04:05:07

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/50573787/how-to-forcefully-remove-mysql-and-mariadb-from-ubuntu-16-04-without-apt-get

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!