MySQL 服务器拒绝卸载

MySQL 服务器拒绝卸载

因此,我输入“apt install mysql-server-8.0”,它返回:

Building dependency tree       
Reading state information... Done
Suggested packages:
  tinyca
The following packages will be upgraded:
  mysql-server-8.0
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,249 kB of archives.
After this operation, 20.5 kB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 306894 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.21-0ubuntu0.20.04.3_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 /var/cache/apt/archives/mysql-server-8.0_8.0.21-0ubuntu0.20.04.3_amd64.deb (--unpack):
 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 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:
 /var/cache/apt/archives/mysql-server-8.0_8.0.21-0ubuntu0.20.04.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试过卸载、重新安装、安装。但都不起作用。我已将相关.deb文件移至/tmp/var/cache/apt/archives/但仍然无法将其从系统中移除。mysql 5.7 似乎仍在这台机器上,尝试删除它会导致相同的错误。我束手无策。Google 没有帮助(遵循了许多指示,包括此处的指示:https://itsfoss.com/dpkg-returned-an-error-code-1/无济于事。

所以我照做了,dpkg --configure -a 结果它又吐了出来:

dpkg: dependency problems prevent configuration of mysql-server-8.0:
 mysql-server-8.0 depends on mysql-server-core-8.0 (= 8.0.20-0ubuntu0.20.04.1); however:
  Version of mysql-server-core-8.0 on system is 8.0.21-0ubuntu0.20.04.3.

dpkg: error processing package mysql-server-8.0 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-8.0

Ubuntu 20.04 LTS

答案1

我认为我已经解决了这个问题(在谷歌上搜索了很多个小时之后):

$sudo nano /var/lib/dpkg/info/mysql-server-core-8.0.prerm

注释掉命令if周围的语句invoke.d(或任何内容),保存并退出 nano。

$sudo apt remove mysql-server-core-8.0

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 124 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 307573 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.21-0ubuntu0.20.04.3) ...
Removing mysql-server-core-8.0 (8.0.21-0ubuntu0.20.04.3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

似乎已经成功了...

答案2

  1. 安装synaptic: “Ubuntu 中的包管理系统 apt 的图形化前端”
$ sudo apt-get install synaptic
  1. 单击Mark All Upgrades选项卡。

该问题可能是由于您的机器上未预先安装的一些依赖项造成的。

相关内容