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

分享于 

9分钟阅读

ubuntu

  繁體

问题

升级到Ubuntu 16.04后,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无法从安装中恢复?我必须重新安装操作系统吗?


答案1

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


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*




答案2


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 会再次工作。


答案3

试试这个

运行此命令清除mysql,将version 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



在我这里可以正常工作。


答案4

清除mysql后,你必须以这种方式安装mysql:


sudo apt-get install mysql-common 


sudo apt-get install mysql-server



以这种方式安装时,将没有安装错误。


答案5

在我这里可以工作


sudo apt-get purge mysql*


sudo apt-get autoremove


sudo apt-get autoclean


sudo apt-get dist-upgrade



然后我再次安装mysql

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


答案6

命令sudo dpkg -r对我不能工作。

我用过sudo apt-get purge mysql-* 卸载所有相关,然后重新安装它们



rep  PAC  PACK  REPA  APT  Repair  
相关文章