简体   繁体   中英

I installed MariaDB and it messed up Mysql and I can't uninstall either

So, I've been messing around with Ubuntu lately and I've been running some Virtual hosts and a Terraria server. I decided to install Clipbucket on one of my Virtual servers and I found this guide: https://www.unixmen.com/install-clipbucket-ubuntu-15-10/ .

I installed MariaDB, as the guide said, not thinking it would mess with my MySQL. My virtual hosts can't connect to MySQL, I can't run 'mysql -u root -p' because I get the error ' ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' after installing MariaDB

I tried to remove MariaDB but it gives this error:

Reading package lists... Done Building dependency tree Reading state information... Done Package 'mariadb-server' is not installed, so not removed You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.7 but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I decided to run apt --fix-broken install and I get this:

Preconfiguring packages ...
(Reading database ... 92893 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.20-0ubuntu0.17.04.1_amd64.deb 
...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-
5.7_5.7.20-0ubuntu0.17.04.1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.7_5.7.20-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Now, I'd like to keep my databases but I don't need really need them, I just don't want to re-make them. I've been trying to figure out what to do for a while and I'm just getting really annoyed ;/

EDIT: I couldn't really do anything including apt-get install because it would tell me that it needed the mysql-5.7 for mysql-server and it would fail. I just ended up re-formatting and obviously everything is working fine, and no, my databases did not work so I will have to re-do those as well.

I had this problem. I used

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5

to get rid of the bad MySQL install. But there were apparently still some mariadb packages that were preventing MySQL from installing. Check using

dpkg -l | grep '\(maria\|mysql\)'

At this point there should be no MySQL packages, but there should be a few mariadb ones. After confirming the presence of these conflicting packages I removed them using

sudo apt-get purge mariadb*

I was then able to successfully reinstall MySQL.

在终端输入: sudo dpkg --reconfigure -asudo apt-get install -f

You can completely uninstall mysql / mariadb as follow:

apt-get purge mariadb-server mariadb-* mysql-*

REMEMBER: purge is like saying [ uninstall and remove the config files too ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM