很长一段时间后,我试图更新Ubuntu20.04,但由于一些MySQL错误,它失败了。我搜索了网页,建议的答案是rm mysql目录。我这样做了,但仍然没有解决问题。
我试过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 errorapt清除/升级/删除失败
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发布于 2022-01-04 03:56:31
如果找不到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如果上面的内容不起作用,那么purge MySQL:
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。
https://askubuntu.com/questions/1384379
复制相似问题