apt-get 升级期间处理包 mysql-community-server 时出错

apt-get 升级期间处理包 mysql-community-server 时出错

我怎么解决这个问题?

root@ip-*******:/# 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-community-server (5.7.19-1ubuntu16.04) ...    
Job for mysql.service failed because the control process exited with error code.    
See "systemctl status mysql.service" and "journalctl -xe" for details.    
invoke-rc.d: initscript mysql, action "start" failed.
    ● mysql.service - MySQL Community Server    
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor reset: enabled)    
   Active: activating (auto-restart) (Result: exit-code) since Fri 2017-09-01 12:16:18 UTC; 4ms ago    
   Main PID: 16929 (code=exited, status=0/SUCCESS)    
dpkg: error processing package mysql-community-server (--configure):    
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= 5.7.19-1ubuntu16.04);   however:
  Package mysql-community-server 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-community-server
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

而且都是同样的错误。

添加:

root@ip-172-31-15-21:/# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu precise-security InRelease
Ign:2 http://archive.ubuntu.com/ubuntu precise InRelease
Ign:3 http://extras.ubuntu.com/ubuntu precise InRelease
Hit:4 http://archive.ubuntu.com/ubuntu precise Release
Hit:6 http://extras.ubuntu.com/ubuntu precise Release
Ign:7 http://archive.canonical.com/ubuntu precise InRelease
Get:8 http://extras.ubuntu.com/ubuntu precise Release.gpg [72 B]
Ign:8 http://extras.ubuntu.com/ubuntu precise Release.gpg
Hit:9 http://archive.canonical.com/ubuntu precise Release
Ign:11 http://it.archive.ubuntu.com/ubuntu precise InRelease
Hit:12 http://it.archive.ubuntu.com/ubuntu precise-updates InRelease
Hit:13 http://it.archive.ubuntu.com/ubuntu precise Release
Fetched 72 B in 2s (25 B/s)
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://archive.ubuntu.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: GPG error: http://extras.ubuntu.com/ubuntu precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192
W: The repository 'http://extras.ubuntu.com/ubuntu precise Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: http://archive.canonical.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://it.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: http://it.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg: Signature by key 630239CC130E1A7FD81A27B140976EAF437D05B5 uses weak digest algorithm (SHA1)
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6

和我的sources.list 在此输入图像描述

答案1

看起来安装在之前的会话中被中断了。

尝试sudo apt-get install -f看看它是否可以修复损坏的依赖项。

如果失败,请清除 MySQL 服务器:

sudo apt-get purge mysql-server mysql-community-server

然后清理并更新:

sudo apt-get autoclean && sudo apt-get clean && sudo apt-get update

进行一般升级:

sudo apt-get upgrade

现在尝试重新安装:

sudo apt-get install mysql-server and mysql-community-server

如果您在根提示符下执行此操作,则不会引导引导sudo命令。

答案2

关于你更新的问题,首先我可以在你的sources.list中看到有一些冗余。例如,您的输出中有以下错误:

W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:1 and /etc/apt/sources.list:6

你的源文件中的第一行有这个

deb http://it.archive.ubuntu.com/ubuntu precise main restricted

第 6 行重复。

因此,为了修复这些错误,我建议您删除输出中指示的所有重复行。 (有很多!)

其次,有这样一个错误:

W: GPG error: http://extras.ubuntu.com/ubuntu precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

要修复此 GNU Privacy Guard 错误,让我们获取该密钥。运行这个:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192

然后通过运行dpkg --configure -aapt-get install -f(或两者)修复损坏的依赖关系。

然后再一次:

apt-get clean && apt-get update

答案3

我自己在 Ubuntu 16.04 LTS (xenial) 上遇到了这个问题。您的 MySQL 日志可能也有错误mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server Upgrade process encountered error and will not continue.

这是我一直在做的解决问题的方法(我还没有调试连接失败的真正问题)。它在最近 3 个 MySQL 更新中一直有效。

首先,以 root 身份运行 MySQL:

# mysql_upgrade --defaults-file=/etc/mysql/debian.cnf

这应该完成且没有错误。

然后编辑该文件/var/lib/dpkg/info/mysql-server-5.7.postinst。在第 320 行附近找到并注释该行:

mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$?

退出并保存文件。再次运行apt-get upgrade,它应该运行干净。

答案4

错误表明您必须尝试安装 mysql-server 但出现问题。配置包时遇到的问题mysql-community-server。您可以尝试运行:

dpkg --configure mysql-community-server

或者:

dpkg-reconfigure mysql-community-server

如果你不想再使用 mysql-server 你可以运行:

apt-get remove mysql-community-server mysql-server

从系统中完全删除这些软件包。那应该可以解决问题。

相关内容