How to forcefully remove MySQL and MariaDB with unmet dependencies, when apt-get and dpkg do not help?
Solution 1
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 @waltinator for your help.
Solution 2
You have confused the packaging system. "Finally, I also manually deleted all files in the directory tree, which contained anything in the name from MySQL or MariaDB". DON'T DO THAT!
The only stable packaging system state that might be available to you now is with NONE of the packages mentioned installed, then begin again, more carefully.
To get to the "NONE" state, remove and purge each package:
PKGS="mysql-server mariadb-client mariadb-server-10.0 mariadb-common mysql-community-server"
sudo apt-get check
sudo apt remove $PKGS
sudo apt purge $PKGS
sudo apt autoremove
sudo apt-get install --reinstall mysql-server
You may get warnings from these commands, probably due to the mess you made. Try to ignore them.
Related videos on Youtube
simhumileco
I'm a full-stack web application developer. I like to deliver top-quality software and learn new things every day.
Updated on September 18, 2022Comments
-
simhumileco over 1 year
I had installed
mysql-server
on my Ubuntu 16.04 LTS and it worked like a charm.Next I installed
mariadb-server
andmariadb-client
. There ware some conflicts with MySQL so I decided to forcefully uninstall all MariaDB components. After that I had problems with MySQL. So I decide to forcefully reinstall MySQL.I could not uninstalled
mysql-server
because there are unmet dependencies after uninstalling MariaDB...So I tried all possible combinations with
apt-get
anddpkg
to forcefully remove the remains of MySQL and MariaDB... Finally, I also manually deleted all files in the directory tree, which contained anything in the name from MySQL or MariaDB...$ mysql The program 'mysql' can be found in the following packages: * mysql-client-core-5.7 * mariadb-client-core-10.0 Try: sudo apt install <selected package>
But I still can not re-install MySQL because the dependencies associated with MariaDB are missing and vice versa...
$ sudo apt-get install -f mysql-server Reading package lists... Done Building dependency tree Reading state information... Done mysql-server is already the newest version (5.7.22-1ubuntu16.04). 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 going to be installed mariadb-server-10.0 : PreDepends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed Depends: mariadb-client-10.0 (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed Breaks: mysql-server mariadb-server-core-10.0 : Depends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed mysql-server : Depends: mysql-community-server (= 5.7.22-1ubuntu16.04) but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Actually I need to have MySQL on my system, but I can't reinstall the Ubuntu.
Please help me to reinstall MySQL.
-
simhumileco about 6 yearsAfter using each of your suggested commands, I had a similar output as I past in second "output section" in my question... @waltinator Do you thing is there any different option without reinstall Ubuntu...?