简体   繁体   English

我安装了 MariaDB,但它搞砸了 Mysql,我也无法卸载

[英]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.所以,我最近一直在玩 Ubuntu,我一直在运行一些虚拟主机和一个泰拉瑞亚服务器。 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/ .我决定在我的一台虚拟服务器上安装 Clipbucket,我找到了这个指南: https ://www.unixmen.com/install-clipbucket-ubuntu-15-10/。

I installed MariaDB, as the guide said, not thinking it would mess with my MySQL.正如指南所说,我安装了 MariaDB,没想到它会弄乱我的 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我的虚拟主机无法连接到 MySQL,我无法运行 'mysql -u root -p' 因为我收到错误 ' ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run安装MariaDB后的/mysqld/mysqld.sock'(2)'

I tried to remove MariaDB but it gives this error:我试图删除 MariaDB,但它给出了这个错误:

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.读取软件包列表...完成 构建依赖关系树 读取状态信息...完成 未安装软件包“mariadb-server”,因此未删除 您可能需要运行“apt --fix-broken install”来更正这些问题。 The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.7 but it is not going to be installed E: Unmet dependencies.以下软件包具有未满足的依赖项: mysql-server :依赖项:mysql-server-5.7 但不会安装 E:未满足的依赖项。 Try 'apt --fix-broken install' with no packages (or specify a solution).尝试不带软件包的“apt --fix-broken install”(或指定解决方案)。

I decided to run apt --fix-broken install and I get this:我决定运行 apt --fix-broken install ,我得到了这个:

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.编辑:我真的不能做任何事情,包括 apt-get install 因为它会告诉我它需要 mysql-server 的 mysql-5.7 并且它会失败。 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.摆脱错误的 MySQL 安装。 But there were apparently still some mariadb packages that were preventing MySQL from installing.但是显然仍然有一些 mariadb 软件包阻止了 MySQL 的安装。 Check using检查使用

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

At this point there should be no MySQL packages, but there should be a few mariadb ones.此时应该没有MySQL包,但应该有几个mariadb包。 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.然后我就能够成功地重新安装 MySQL。

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

You can completely uninstall mysql / mariadb as follow:您可以完全卸载mysql / mariadb如下:

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

REMEMBER: purge is like saying [ uninstall and remove the config files too ]记住:清除就像在说 [ 也卸载并删除配置文件 ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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