如何重新安装损坏的 mysql 包

如何重新安装损坏的 mysql 包

尝试修复损坏的 mysql 安装,这是从 debian 6.0 升级到 7.0 后发生的。我的 /etc/apt/sources.list 中有 dotdeb.org 包。

root@ginger:/var/log/mysql# apt-get install mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 mysql-server-5.5 : Depends: mysql-client-5.5 (>= 5.5.31+dfsg-0+wheezy1) but 5.5.30-1~dotdeb.0 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

运行 apt-get -f install 会导致:

root@ginger:/var/log/mysql# apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libfont-freetype-perl libfontenc1 libgmp3c2 libgsf-1-114 libgsf-1-common libpython2.6 libxcb-render-util0
  libxfont1 mysql-client-core-5.5 xfonts-encodings xfonts-utils
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  mysql-client-5.5
Suggested packages:
  libterm-readkey-perl
The following packages will be upgraded:
  mysql-client-5.5
1 upgraded, 0 newly installed, 0 to remove and 141 not upgraded.
178 not fully installed or removed.
Need to get 1,923 kB of archives.
After this operation, 6,752 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.us.debian.org/debian/ wheezy/main mysql-client-5.5 amd64 5.5.31+dfsg-0+wheezy1 [1,923 kB]
Fetched 1,923 kB in 0s (2,323 kB/s)
Reading changelogs... Done
(Reading database ... 36477 files and directories currently installed.)
Preparing to replace mysql-client-5.5 5.5.30-1~dotdeb.0 (using .../mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb) ...
Unpacking replacement mysql-client-5.5 ...
dpkg: error processing /var/cache/apt/archives/mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mysqlcheck', which is also in package mysql-client-core-5.5 5.5.30-1~dotdeb.0
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-client-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ginger:/var/log/mysql#

知道如何删除 mysql 并全新安装吗?

答案1

首先通过以下命令获取超级用户权限。 sudo -i将授予您 root 访问权限。

以下对我有用:

apt-get -f install -o Dpkg::Options::="--force-overwrite"

接下来是:

apt-get purge mysql\*
rm -rf /var/lib/mysql
rm -rf /etc/mysql
dpkg -l | grep -i mysql
apt-get clean
updatedb
apt-get install mysql-client-core-5.5  mysql-client-5.5 mysql-common mysql-server-5.5

对于 MySql5.6 使用下面的

apt-get install mysql-client-core-5.6 mysql-client-5.6 mysql-server-5.6

确保备份所有数据,因为这将删除所有内容。

我找到了这个解决方案这里

答案2

我已经完成了这项工作:

apt-get remove --purge mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5
apt-get -f install -o Dpkg::Options::="--force-overwrite" mysql-server

这重新创建了我删除的 /ets/mysql 和 /var/lib/mysql 目录,并使用默认值。我找到了 OP 的这个软件包列表dpkg -l | grep -i mysql

答案3

看起来您缺少 dpkg。您在使用 apt-get 安装其他软件包时遇到问题吗?尝试 wget mysql 二进制文件,然后使用 dpkg 安装它。如果您收到有关命令的错误或软件包 dpkg 不存在,那么您就知道问题出在 dpkg 上,您需要将其安装到您的系统上,然后尝试安装它。

相关内容