Debian 11升级MySQL 5.7至8.0时依赖错误问题排查
Debian 11升级MySQL 5.7到8.0时mysql-common版本冲突问题
系统是从Jessie升级到Bullseye的Debian 11,原本通过apt-get install mysql-server安装了MySQL 5.7,现在尝试升级到8.0版本。按照《使用MySQL APT仓库替换原生分发版MySQL》指南操作时,出现mysql-common 5.8(Debian原生包)与8.0(MySQL官方源)的版本冲突,具体操作及报错如下:
操作步骤及报错
1. 卸载旧版本MySQL及依赖
sudo apt-get remove automysqlbackup mariadb-common libmariadb3 sysbench mysql-community-client mysql-community-server mysql-common mysql-server mysql-client sudo apt-get autoremove
2. 配置MySQL 8.0官方源
sudo wget https://repo.mysql.com//mysql-apt-config_0.8.24-1_all.deb sudo dpkg -i mysql-apt-config_0.8.24-1_all.deb sudo apt-get update
3. 安装MySQL 8.0时报错
执行sudo apt-get install mysql-server后出现依赖错误:
Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: mysql-community-server : Depends: mysql-common (>= 8.0.31-1debian11) Depends: mysql-client (= 8.0.31-1debian11) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
尝试解决但无效的操作
尝试单独安装mysql-common时,系统始终安装Debian原生的5.8版本,即使清除残留配置也没用:
查看可用的mysql-common版本:
sudo apt list -a mysql-common
输出:
Listing... Done mysql-common/unknown 8.0.31-1debian11 all [residual-config] mysql-common/stable,now 5.8+1.0.7 all [residual-config]
执行安装命令sudo apt-get install mysql-common,结果还是安装5.8版本:
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: mysql-common 0 upgraded, 1 newly installed, 0 to remove and 49 not upgraded. Need to get 0 B/7,464 B of archives. After this operation, 34.8 kB of additional disk space will be used. Selecting previously unselected package mysql-common. (Reading database ... 82684 files and directories currently installed.) Preparing to unpack .../mysql-common_5.8+1.0.7_all.deb ... Unpacking mysql-common (5.8+1.0.7) ... Setting up mysql-common (5.8+1.0.7) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Scanning processes... Scanning candidates... Scanning linux images... Running kernel seems to be up-to-date. Restarting services... systemctl restart containerd.service No containers need to be restarted. No user sessions are running outdated binaries.
临时解决方法(非规范操作)
手动从deb包提取并安装mysql-common 8.0版本:
wget https://repo.mysql.com//mysql-apt-config_0.8.24-1_all.deb tar -xvf mysql-apt-config_0.8.24-1_all.deb sudo dpkg -i mysql-common_8.0.31-1debian11_amd64.deb
之后再执行sudo apt-get install mysql-server即可正常完成安装,但这种方法不符合APT包管理的规范。
请问我的操作哪里出现了问题?
内容的提问来源于stack exchange,提问作者splattru
相关产品推荐
相关产品推荐

