如何修复损坏的软件包安装(mysql)


15

升级到Ubuntu 16.04之后,我注意到mysql出现令人难以置信的错误。确信这是一个损坏的设置,我尝试运行mysql清除。这似乎并没有删除所有内容,所以我尝试自己做:

sudo rm -r /etc/mysql
sudo rm -r /usr/share/mysql-workbench
sudo rm -r /usr/share/mysql
sudo rm -r /usr/share/mysql-common

这是一个错误。永远不要尝试这样做。现在,mysql甚至无法正确安装。我试过重新安装依赖项:

sudo apt-get install --reinstall $(apt-cache depends mysql-server | grep -Po 'Depends:\s+\K[^ ]+$' | tr '\n' ' ' )

和包本身:

sudo apt install mysql-workbench mysql-server --reinstall

但是我遇到各种各样的隐秘错误,例如:

sudo apt-get install --reinstall mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not         upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for mysql-server:amd64

并卸载

sudo apt-get remove mysql-common
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:
 libmysqlclient20 : Depends: mysql-common (>= 5.5) but it is not going to be installed
 mariadb-client-core-10.0 : Depends: mariadb-common (>= 10.0.24-7) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

或者如果我重新配置

sudo dpkg --configure -a
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

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

或者如果我强制安装:

sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

或者,如果我进行清除:

sudo apt-get -f purge mysql-server 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 159 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 348226 files and directories currently installed.)
Removing mysql-server (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt无法从部分安装中恢复吗?我必须重新安装操作系统吗?


您是否尝试过采用一种更简单的方法sudo apt-get install --reinstall mysql
Videonauth

我更新了这些错误,以包括这些错误
乔纳森(Jonathan),

也许您想聊天,我们看看是否可以解决。
Videonauth

Answers:


22

执行以下操作清除损坏的包装:

sudo apt-get clean
sudo apt-get update
sudo dpkg -r mysql-client-5.7
sudo dpkg -r mysql-server-5.7
sudo dpkg -r libmysqlclient20:i386
sudo dpkg -r libmysqlclient20:amd64
sudo dpkg -r libmysqlclient18:amd64
sudo dpkg -r mysql-common
sudo dpkg -r mysql 

之后,使用以下命令重新安装它:

sudo apt-get install mysql mysql-client* mysql-server*

非常感谢!!逐个删除依赖项是摆脱apt-get卡住的唯一选择
stackMonk

为此+1。感谢您提到要删除的完整软件包堆栈,以便MySQL删除。它也对我有用。
Parveen Verma,

在我的ubuntu 18.04上,尝试删除mysqlclient(运行第3条命令)时产生了以下问题:依赖关系问题阻止删除mysql-client-5.7:mysql-server-5.7取决于mysql-client-5.7(> = 5.7.26-0ubuntu0.18.04。 1)。dpkg:错误处理软件包mysql-client-5.7(--remove):依赖问题-无法删除处理时遇到错误:mysql-client-5.7,但运行sudo apt清除mysql-server mysql-server-5.7 mysql-server-从此处开始的 core-5.7 askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server似乎删除了该实例
Carmine

现在我在尝试安装sudo apt install openjdk-8-jre openjdk-8-jdk时遇到了很多错误。
胭脂红

我能够找到以前阻止我清理mysql更新的任何尝试的进程,的确,我停止了在系统中运行的实例,然后从链接的其他解决方案中清除了该进程。之后,我确定我的系统已更新。确实,我发现以某种方式错过了许多更新。此后到目前为止,需要本身mysql实例的java sdk的安装似乎进展顺利
Carmine

13

感谢@Videonauth

sudo dpkg -r mysql-client-5.7
sudo dpkg -r mysql-server-5.7
sudo dpkg -r libmysqlclient20:i386
sudo dpkg -r libmysqlclient20:amd64
sudo dpkg -r libmysqlclient18:amd64
sudo dpkg -r mysql-common

然后运行:

sudo apt-get purge mysql\* mariadb\* libmysql\* libmariadb\*

如果失败,则运行sudo dpkg -r <failedpackage>,如果失败,则删除依赖于它的软件包。如果重复,最终apt-get将再次起作用。

另请参见dpkg和aptitude / apt-get有什么区别?


即使其他软件包依赖它们,也要删除这些libmysqlclient软件包,然后清除所有内容就可以了。虽然现在我得到mysql_upgrade错误。
skerit,2016年

我从来没有mysql_upgrade错误。但是您可能必须删除更多软件包。我想这取决于哪个软件包被破坏了。有一种方法可以搜索与mysql相关的所有已安装软件包,但我忘记了如何。我认为这是通过grep传递的dpkg list命令
乔纳森(Jonathan),

9

尝试这个,

运行此命令清除mysql,将5.7版替换为已安装的版本

sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server

运行它来清理和更新软件包

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install

终于安装mysql

sudo apt install mysql-server

这对我有用。


1
这对我有用,选择的答案没有(失败了sudo dpkg -r mysql-client-5.7
jeff-h,

谢谢!我一直在寻找解决方案数小时,这是唯一的答案!
mirza

1
这对我有用。本教程也有帮助。
nwaweru

4

mysql如上所示清除后,您必须以这种方式安装mysql:

sudo apt-get install mysql-common 
sudo apt-get install mysql-server

以这种方式安装时,不会出现安装错误。


这对我
有用

2

我不知道确切的原因,但是所有这些方法都不适合我。就我而言,纠正该问题的过程是:

sudo apt-get purge mysql-*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql*

然后重启

终于,我能够跑步了 sudo apt-get install mysql-server


谢谢它为我工作
-Nijo

1

这对我有用

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

然后在那之后我再次用

sudo apt-get install mysql-server 现在工作正常。


0

命令sudo dpkg -r对我不起作用。

我曾经sudo apt-get purge mysql-*先卸载所有已发布的分页,然后重新安装

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.