MySQL 包不想安装

MySQL 包不想安装

我正在尝试在 Debian Jessie 上安装软件包,mysql-servermysql-client得到以下输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-client is already the newest version.
mysql-server is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我尝试过在不同论坛上找到的各种解决方案,但都没有用。

例如apt-get -f autoremove

造成该问题的原因是什么?如何解决?

编辑

该命令apt-get -f install输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  mariadb-common
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  mysql-server-5.5
Suggested packages:
  mailx tinyca
Recommended packages:
  libhtml-template-perl
The following NEW packages will be installed:
  mysql-server-5.5
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/1,620 kB of archives.
After this operation, 29.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 51712 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.5_5.5.47-0+deb8u1_armhf.deb ...
Aborting downgrade from (at least) 10.0 to 5.5.
If are sure you want to downgrade to 5.5, remove the file
/var/lib/mysql/debian-*.flag and try installing again.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.5_5.5.47-0+deb8u1_armhf.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.5_5.5.47-0+deb8u1_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑2

删除建议的文件/var/lib/mysql/debian-*.flag然后apt-get -f autoremove再次运行会得到以下输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  mariadb-common
Use 'apt-get 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.
Setting up mysql-server-5.5 (5.5.47-0+deb8u1) ...
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
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
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

当我需要在 MariaDB 之后安装 5.7 时遇到了这个错误,erase并且autoremove没有帮助。

警告:此命令将会摧毁你的数据!如果你需要数据,就不要运行它。我不需要它(一台新服务器),所以我只是rm -rf /var/lib/mysql/*,它立即有所帮助。

答案2

如果确定要降级到 5.5,请删除文件 /var/lib/mysql/debian-*.flag 并尝试再次安装。

从您的终端输出可以理解,当您尝试安装时,系统已经安装了较新版本的 mysql-server。

您可以使用显示已安装软件包(包括版本和其他详细信息)的命令进行检查:

dpkg -l | grep mysql-server

然后你就可以确定你是否拥有 mysqlserver,以及你拥有哪个版本。因此,你可以继续使用已安装的版本,或者如果你想强制安装旧包,终端输出会要求你删除一个文件:/var/lib/mysql/debian-*.flag

sudo rm -f /var/lib/mysql/debian-*.flag

请小心使用 rm 命令(特别是使用 sudo),删除后,重新安装就可以正常工作。

相关内容