AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1344875
Accepted
DonP
DonP
Asked: 2021-06-10 15:09:13 +0800 CST2021-06-10 15:09:13 +0800 CST 2021-06-10 15:09:13 +0800 CST

Ubuntu 20.10 无法安装或卸载 MySQL

  • 772

在升级到 21.04 LTS 之前尝试更新我的系统时,MySQL 出现了无法更新或修复的错误,因此我将其清除:

sudo apt purge mysql-server-8.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-server-8.0*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 555934 files and directories currently installed.)
Purging configuration files for mysql-server-8.0 (8.0.17-0ubuntu2) ...
Processing triggers for systemd (246.6-1ubuntu1.3) ...

但是,现在它不会重新安装。

sudo apt-get install mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
                Conflicts: mysql-client-core-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed

有些东西显然坏了,但不知道怎么办?

以下是基于评论的一些附加输出:

Sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu groovy-security InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
sudo apt clean

sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt update && sudo apt upgrade
Hit:1 http://archive.ubuntu.com/ubuntu groovy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu groovy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu groovy-security InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo dpkg --configure -a

sudo apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

然后尝试安装 mysql-client ,尽管没有安装它,但它在 mysql-client 上出现错误:

sudo apt install mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
                Conflicts: mysql-client-core-8.0 but 

8.0.25-0ubuntu0.20.10.1 is to be installed

E: Unable to correct problems, you have held broken packages.

其他尝试:

sudo apt install mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mysql-common : Conflicts: mysql-client-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
                Conflicts: mysql-client-core-8.0 but 8.0.25-0ubuntu0.20.10.1 is to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt purge mysql-client-8.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'mysql-client-8.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sudo apt purge mysql-client-core-8.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'mysql-client-core-8.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

似乎在告诉我未安装 MySQL,但它的安装存在冲突!我该如何解决这个难题?

upgrade
  • 1 1 个回答
  • 1286 Views

1 个回答

  • Voted
  1. Best Answer
    matigo
    2021-06-10T17:07:21+08:002021-06-10T17:07:21+08:00

    这有时可以通过清理apt一下来解决。在终端中,试试这个:

    sudo apt update
    sudo apt clean
    sudo apt autoremove
    

    现在尝试安装 MySQL 客户端。如果错误仍然存​​在,那么您可能需要“修复”安装:

    sudo apt --fix-broken install
    sudo apt update && sudo apt upgrade
    sudo dpkg --configure -a
    sudo apt install -f
    

    现在您应该可以安装客户端了:

    sudo apt install mysql-client
    

    注意:虽然您已经删除了 MySQL 服务器,但仍有一些文件在/var/lib/mysql. 这些是卸载后故意留下的。如果您不需要任何以前可用的数据库,请随意删除此目录。您可能还会/etc/mysql留下来,如果您不再需要配置文件,也可以将其删除。


    从 Ubuntu (18.04 和更新版本) 清理 MySQL

    如果 MySQL 拒绝正常运行,那么您可能需要按照以下步骤将其从系统中彻底清除:

    1. 打开终端(如果尚未打开)
    2. 确保 MySQL 进程已停止(即使它没有运行):
      sudo systemctl stop mysqld
      
    3. 从系统中清理 MySQL 包:
      sudo apt purge mysql-server mysql-common mysql-server-core-* mysql-client-core-*
      
      而且,为了完整起见,让我们确保系统上没有安装 MariaDB:
      sudo apt purge mariadb-server 
      
    4. 检查任何剩余的软件包:
      sudo dpkg -l | grep mysql
      
      理想情况下,您将获得零结果。但是,如果仍然安装了任何东西,您可能会看到如下内容:
      ii  libmysqlclient21:amd64                     8.0.25-0ubuntu0.20.04.1                    amd64        MySQL database client library
      ii  php-mysql                                  2:7.4+75                                   all          MySQL module for PHP [default]
      ii  php7.4-mysql                               7.4.3-4ubuntu2.4                           amd64        MySQL module for PHP
      
      如果您确实看到了值,apt purge它们会脱离系统:
      sudo apt purge php-mysql php7.4-mysql libmysqlclient21
      
      对 MariaDB 执行相同的操作:
      sudo dpkg -l | grep mariadb
      
    5. 清理 MySQL 目录的文件系统(MariaDB 也使用):
      sudo rm -rf /var/lib/mysql/
      sudo rm -rf /etc/mysql/
      sudo rm -rf /var/log/mysql
      
      仔细检查并清理这些文件:
      sudo find / -iname 'mysql*' -exec rm -rf {} \;
      
      重要提示:此命令将从您的系统中删除任何以 开头的文件,mysql而无需请求确认。请务必小心谨慎地使用它。
    6. 删除 MySQL 用户帐户和组:
      sudo deluser --remove-home mysql
      sudo delgroup mysql
      
      如果您无法删除该组,请检查是否有其他用户帐户属于 MySQL 组:
      less /etc/passwd
      
      如果找到,请从组中删除用户,然后delgroup再删除。
    7. 删除任何可能用于安装特定 MySQL 版本的第三方 PPA
    8. 更新您的来源列表:
      sudo apt autoremove -y
      sudo apt autoclean
      
    9. 喝杯咖啡,因为是时候休息了☕️

    只要您的机器上没有配置某种 XAMPP 系统,这应该完全消除您机器上的数据库引擎。

    • 3

相关问题

  • 在自定义安装以维护升级路径时,应遵循哪些准则?

  • 使用 apt-get upgrade 时如何强制安装内核更新?

  • 从 8.04 LTS 升级到 10.04 LTS 的体验?

  • 分销升级的合理途径

  • 在不使用标准升级系统的情况下升级有哪些替代方案?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve