dpkg: 处理软件包 mysql-server 时出错(--configure)

dpkg: 处理软件包 mysql-server 时出错(--configure)

当我通过终端和软件更新程序removeautoremoveinstall等时出现以下错误。upgrade

结果sudo apt-get autoremove如下所示。错误提示 dpkg 错误处理 mysql-server。

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.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
No apport report written because the error message indicates its a followup error from a previous failure.
                      dpkg: error processing package mysql-server-5.5 (--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.5; however:
  Package mysql-server-5.5 is not configured yet.

 dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

也参考了此链接:关联

帮忙重新配置mysql。

还尝试了 dpkg 重新配置。(在重复问题之前请考虑)

编辑1:我的 ubuntu 版本是 14.04 LTS

编辑2sudo apt-get upgrade结果:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... 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.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--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.5; however:
  Package mysql-server-5.5 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.5
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo dpkg --configure -a结果:

Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--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.5; however:
  Package mysql-server-5.5 is not configured yet.

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

sudo apt-get remove 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, 131 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 209845 files and directories currently installed.)
Removing mysql-server (5.5.49-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.49-0ubuntu0.14.04.1) ...
 start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

这对我有用

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 

现在它运行良好。

答案2

apt这些方法对我都不起作用,请尝试这个:

查找锁定进程

$ ps -eaf
root      7316     1  0 00:19 ?        00:00:00 /usr/bin/dpkg --status-fd 35 --configure --pending
root      7808  7316  0 00:19 ?        00:00:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-se
root      7817  7808  0 00:19 ?        00:00:00 /bin/bash /var/lib/dpkg/info/mysql-server-5.7.postinst configure
mysql     7973  7817  0 00:20 ?        00:00:00 mysqld --user=mysql --init-file=/var/lib/mysql-files/tmp.iNyY06ty0K --so

杀了它

sudo kill -9 7973,基本上就mysql一个。

现在清除

sudo apt-get purge mysql-server-5.7 # Or whatever you are trying to purge.

答案3

如果端口 (3306) 被其他应用程序使用,也可能会发生此错误。就我而言,我有一个运行 mysql 的 docker 容器,它使用 3306 端口,因此我的本地 mysql 安装配置失败。

$ sudo netstat -nltp | grep LISTEN | grep 3306
$ sudo netstat -nltp | grep LISTEN | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      1017033/docker-prox 

sudo apt purge --auto-remove mysql*
sudo rm -r /etc/mysql
sudo rm -r /var/lib/mysql*

sudo apt install mysql-client-8.0 mysql-server-8.0 --fix-broken -y

答案4

我遇到了 yes Unix 二进制文件,它非常愚蠢:它只是无休止地输入 y(试试看,你可以在终端中运行 yes)

所以下面的方法就可以了(我在 dockerfile 中使用了这个)

yes | apt-get install mysql-community-server

相关内容