Debian

無法使用 apt-get 在 Debian 6 伺服器上升級 mySql

  • January 12, 2016

我執行一個 Debian 6 伺服器並用它來託管十幾個基於 LAMP 的網站。我將它配置為在軟體更新可用時向我發送電子郵件,今天早上我收到了 6 個與 mySql 相關的新可用更新的通知:

mysql-伺服器,mysql-客戶端,mysql-common

以及其他一些依賴項。我試圖執行

apt-get 更新 apt-get 升級

一切順利,直到升級過程遇到 mysql-client。我得到的錯誤如下:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be upgraded:
  mysql-client-5.5
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,772 kB of archives.
After this operation, 7,049 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y

Reading changelogs... Done

(Reading database ... 84121 files and directories currently installed.)
Preparing to replace mysql-client-5.5 5.5.38-1~dotdeb.0 (using .../mysql-client-5.5_5.5.46-0+deb6u1_amd64.deb) ...

Unpacking replacement mysql-client-5.5 ...
dpkg: error processing /var/cache/apt/archives/mysql-client-5.5_5.5.46-0+deb6u1_amd64.deb (--unpack):

trying to overwrite '/usr/share/man/man1/mysql.1.gz', which is also in package mysql-client-core-5.5 5.5.38-1~dotdeb.0
configured to not write apport reports
                                 dpkg-deb: subprocess paste killed by signal (Broken pipe)

Processing triggers for man-db ...

Errors were encountered while processing:

/var/cache/apt/archives/mysql-client-5.5_5.5.46-0+deb6u1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我沒有足夠的經驗來完全理解發生了什麼。我嘗試按照消息的建議執行 apt-get -f install ,但什麼也沒發生。我還嘗試刪除 mysql-client (想法是“我刪除了這個,然後從頭開始重新安裝”)但此操作也失敗並出現相同的錯誤。我試圖清除 mysql,但係統也無法完成該操作。

目前,我重新啟動了服務,現在一切看起來都正常了,但是這次升級失敗的問題仍然存在。

這是我在伺服器上安裝的所有 mysql 相關軟體包的 grep:

~# dpkg -l | grep -i mysql
ii  libdbd-mysql-perl                     4.016-1                      Perl5 database interface to the MySQL database
ii  libmysqlclient16                      5.1.73-1+deb6u1              MySQL     database client library
ii  mysql-client                          5.5.46-0+deb6u1              MySQL database client (metapackage depending on the latest version)
ii  mysql-client-5.5                      5.5.38-1~dotdeb.0            MySQL database client binaries
ii  mysql-client-core-5.5                 5.5.38-1~dotdeb.0            MySQL database core client binaries
ii  mysql-common                          5.5.38-1~dotdeb.0            MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-common-5.5                      5.5.46-0+deb6u1              MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                          5.5.46-0+deb6u1              MySQL database server (metapackage depending on the latest version)
rc  mysql-server-5.1                      5.1.73-1+deb6u1              MySQL database server binaries and system database setup
iU  mysql-server-5.5                      5.5.46-0+deb6u1              MySQL database server binaries and system database setup
ii  mysql-server-core-5.5                 5.5.46-0+deb6u1              MySQL database server binaries
ii  php5-mysql                            5.4.45-1~dotdeb+6.1          MySQL module for php5
rc  php5-mysqlnd                          5.4.45-1~dotdeb+6.1          MySQL module for php5 (Native Driver)
ii  phpmyadmin                            4:3.3.7-10                   MySQL web administration tool

添加 apt-get remove 的結果

~# apt-get remove mysql-server-5.5
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 : Depends: mysql-server-5.1 but it is not going to be installed or
                        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).

誰能幫我理解如何解決這個問題?提前謝謝你,西蒙娜

正如@M Somerville 所解釋的那樣,您使用的 dotdeb 儲存庫先前安裝的軟體包與現在包含 mysql 5.5 更新版本的官方 debian 儲存庫之間存在衝突。

您需要做的是完全刪除 mysql 5.5,然後安裝儲存庫中可用的最新版本。

這解決了我的問題,沒有任何數據/配置失去:

apt-get remove mysql-client-5.5 mysql-client-core-5.5 mysql-client mysql-server-5.5 mysql-server

然後

apt-get install mysql-client mysql-server

無論如何,在您嘗試此操作之前,我不能足夠強調備份的重要性。

祝你好運

引用自:https://serverfault.com/questions/743375