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 / 问题 / 1384379
Accepted
Damn Vegetables
Damn Vegetables
Asked: 2021-12-31 02:36:15 +0800 CST2021-12-31 02:36:15 +0800 CST 2021-12-31 02:36:15 +0800 CST

mysql-server-8.0 错误阻止 apt 安装

  • 772

很长一段时间后我尝试更新 Ubuntu 20.04,但由于一些 MySQL 错误而失败。我在网上搜索,建议的答案是rmmysql 目录。我这样做了,但它仍然没有解决问题。

我试过dpkg --remove --force-all mysql-server-8.0了,但它说:

Unit mysql.service could not be found. dpkg: error while cleaning up:  
...post-installation script subprocess returned error

apt purge/upgrade/remove 失败

The package mysql-server-8.0 needs to be reinstalled

我不记得安装了 MySQL,但即使我安装了,我也不需要 MySQL。我根本不在乎。我怎样才能完全核对 MySQL 并重新开始工作?

test@ubuntu:~$ sudo apt install --reinstall mysql-server-8.0 
Reading package lists... Done 
Building dependency tree
Reading state information... Done
E: The package mysql-server-8.0 needs to be reinstalled, but an archive for it can't be found.
test@ubuntu: $ sudo apt purge mysql-server-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package mysql-server-8.0 needs to be reinstalled, but an archive for it can't be found.
test@ubuntu:~$ sudo apt install mysql-server --reinstall
Reading state information... Done
Reading package lists... Done 
Building dependency tree 
E: The package mysql-server-8.0 needs to be reinstalled, but an archive for it can't be found. 

~$ sudo apt purge mysql-server-core-8.0 -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  galera-3 libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
  libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
  libhtml-template-perl libllvm10 libllvm11 libmecab2 libreadline5
  libterm-readkey-perl linux-headers-5.4.0-42 linux-headers-5.4.0-42-generic
  linux-image-5.4.0-42-generic linux-modules-5.4.0-42-generic
  linux-modules-extra-5.4.0-42-generic mecab-ipadic mecab-ipadic-utf8
  mecab-utils socat
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
  mysql-server-8.0* mysql-server-core-8.0*
0 to upgrade, 0 to newly install, 2 to remove and 3 not to upgrade.
1 not fully installed or removed.
After this operation, 137 MB disk space will be freed.
Do you want to continue? [Y/n] 
dpkg: error processing package mysql-server-8.0 (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
dpkg: too many errors, stopping
Errors were encountered while processing:
 mysql-server-8.0
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

和

$ sudo dpkg -i --force-all mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb
(Reading database ... 471728 files and directories currently installed.)
Preparing to unpack mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: warning: old mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing archive mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb (--install):
 new mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb
apt
  • 1 1 个回答
  • 2474 Views

1 个回答

  • Voted
  1. Best Answer
    Error404
    2022-01-04T19:56:31+08:002022-01-04T19:56:31+08:00

    如果找不到 Mysql 的存档,请尝试手动安装存档。

    首先,尝试下载 deb 文件是否有效:

    sudo apt download mysql-server-8.0
    

    现在,使用dpkg编译存档:

    sudo dpkg -i --force-all ./*.deb
    

    如果上述方法不起作用,请尝试:

    首先,单击此处,将开始下载一个 deb 文件。

    之后使用dpkg -i命令安装.deb文件。

    我不确定,但您也可以运行以下命令来下载 deb 并安装它:

    wget https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb && sudo dpkg -i *.deb
    

    之后,运行上面的:

    sudo apt install mysql-server-8.0
    

    如果上述方法不起作用,那么purgeMySQL:

    sudo dpkg -P mysql*
    

    这是删除 MySQL 的另一种方法:

    sudo mv /var/lib/dpkg/info/mysql* ~/ && sudo apt -f install
    

    如果以上所有方法都不起作用,那么最后一件事是:

    首先,将内容更改/etc/apt/sources.list为:

    deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
    
    deb http://archive.canonical.com/ubuntu focal partner
    deb-src http://archive.canonical.com/ubuntu focal partner
    

    然后运行apt update:

    sudo apt download mysql-server-8.0
    sudo dpkg -i --force-all ./*.deb
    

    如果那也不起作用

    如果上述方法不起作用,那么我建议重新安装 Ubuntu。

    • 1

相关问题

  • 如何编写 shell 脚本来安装应用程序列表?

  • 如何查看存档中可用的软件包的所有版本?

  • 是否可以说出我安装的哪些软件包不在原版安装中?

  • 如何删除 PPA?

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

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