我正在尝试安装 mysql-server,但出现以下错误:
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.25-0ubuntu0.18.04.2).
The following package was automatically installed and is no longer required:
python-gi
Use 'sudo apt autoremove' to remove it.
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.7 (5.7.25-0ubuntu0.18.04.2) ...
Renaming removed key_buffer and myisam-recover options (if present)
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.25, use --force if you still need to run mysql_upgrade
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess 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)
从错误中我了解到我需要对 mysql-server-5.7 依赖项进行一些配置。是吗?
答案1
可能是这个问题的重复: dpkg: 处理软件包 mysql-server 时出错(--configure)
您已安装子进程,安装后脚本返回错误退出状态 1 ,安装后脚本是 *.postinst 文件。在您的情况下,/var/lib/dpkg/info/mysql-server-5.5.postinst 在软件包安装的配置步骤上运行。当它失败时,您被锁定,因为即使删除操作也会尝试完成停止的配置步骤,然后删除软件包。因此,打开 /var/lib/dpkg/info/mysql-server-5.5.postinst 并手动编辑它,并在第二行添加 set -e 以忽略任何错误(基本上,invoke-rc.d/init 无法重新启动 mysql 服务)。之后手动重新启动它。 – user.dz 2016 年 7 月 1 日 3:42
答案2
似乎在之前的尝试中安装被中断了。您正面临依赖关系中断的问题。由于您已经尝试运行但--force
无济于事,请先清除现有的 MySqL 安装
sudo apt-get purge mysql-server
然后清理残余。更新系统。进行全面升级。
sudo apt-get autoclean && sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade
现在重新安装
sudo apt-get install mysql-server