我正在尝试在 ubuntu 22.04 LTS 上安装 mysql-server,但收到以下 dpkg 错误消息。我该如何修复此问题?
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-ore-8.0
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 6 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/21.1 MB of archives.
After this operation, 182 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 201995 files and directories currently installed.)
Preparing to unpack .../mysql-common_1%3a10.5.15+maria~focal_all.deb ...
Unpacking mysql-common (1:10.5.15+maria~focal) ...
Selecting previously unselected package mysql-client-core-8.0.
Preparing to unpack .../mysql-client-core-8.0_8.0.28-0ubuntu4_amd64.deb ...
Unpacking mysql-client-core-8.0 (8.0.28-0ubuntu4) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../mysql-client-8.0_8.0.28-0ubuntu4_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.28-0ubuntu4) ...
Selecting previously unselected package mysql-server-core-8.0.
Preparing to unpack .../mysql-server-core-8.0_8.0.28-0ubuntu4_amd64.deb ...
Unpacking mysql-server-core-8.0 (8.0.28-0ubuntu4) ...
Setting up mysql-common (1:10.5.15+maria~focal) ...
Selecting previously unselected package mysql-server-8.0.
(Reading database ... 202191 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.28-0ubuntu4_amd64.deb ...
Unpacking mysql-server-8.0 (8.0.28-0ubuntu4) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_8.0.28-0ubuntu4_all.deb ...
Unpacking mysql-server (8.0.28-0ubuntu4) ...
Setting up mysql-client-core-8.0 (8.0.28-0ubuntu4) ...
Setting up mysql-server-core-8.0 (8.0.28-0ubuntu4) ...
Setting up mysql-client-8.0 (8.0.28-0ubuntu4) ...
Setting up mysql-server-8.0 (8.0.28-0ubuntu4) ...
/var/lib/dpkg/info/mysql-server-8.0.postinst: line 194: /usr/share/mysql-
common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 127
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
尽管运行命令mysqld -V
会产生以下输出 -
适用于 x86_64 上的 Linux ((Ubuntu)) 的 /usr/sbin/mysqld Ver 8.0.28-0ubuntu4
执行该命令sudo service mysql start
会产生以下错误代码 -
mysql.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status mysql.service”和“journalctl -xeu mysql.service”。
答案1
重新发布我对类似问题的回答这里。我能够在 Ubuntu 22.04 上使用以下方法解决此问题arief21 的解决方案20.04 上也有类似问题,它本身就是从这里。
概述
问题似乎出在第一次安装失败后文件系统中残留的一些部分初始化。因此,解决方案基本上就是确保清除安装失败期间添加或修改的所有内容。
我没有时间进行深入研究,所以我不知道究竟是哪些文件导致了这个问题,但如果有人可以提供更多见解,请在下面评论,以便为未来需要更细致解决方案的读者提供帮助。
清除相关包
- 确保 MySQL 没有运行:
sudo systemctl stop mysql
- 然后清除所有 MySQL 包:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
- 然后删除所有 MySQL 文件:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
- 最后清理所有不需要的包:
sudo apt autoremove
sudo apt autoclean
- 在继续之前重启一下也没什么坏处
sudo reboot
现在,所有残留的配置问题都已被清除,您应该能够再次运行安装命令。
MySQL Apt 软件包说明
我也读过这里有些人在安装时遇到问题mysql-server
在 Jammy 上,建议安装特定的mysql-server-8.0
和mysql-server-core-8.0
软件包。我不能 100% 确定这个事实,因为mysql-server
在完全清除之后我没有再尝试元软件包。
sudo apt install mysql-server-core-8.0 mysql-server-8.0
希望这可以帮助!
答案2
您需要至少 1 GB 的 RAM 才能安装 MySQL 服务器。我尝试使用最便宜的 DO 实例安装 MySQL 服务器,但一直失败。事实证明,MySQL 服务器至少需要 1 GB 才能运行。希望这能有所帮助。
答案3
自从我从第三方存储库安装了最新的 MariaDB 版本后,我也遇到了同样的问题。
输出中的这一行提示了这个问题:
/usr/share/mysql-common/configure-symlinks: No such file or directory
当尝试删除/清除软件包mysql-common
apt 时,它声称依赖许多其他应用程序包。
解决方案
- 去除mysql 服务器移除
apt remove mysql-server mysql-server-8.0
所有剩余mariadb 服务器包也是如此。 - 从 MariaDB 中删除任何第三方存储库。
- 使用突触图形用户界面 (GUI) 包管理器或者
- 手动编辑文件夹并用前导字符
/etc/apt/sources.list.d/
注释掉行#
或者 - 重命名/移动/删除文件
/etc/apt/sources.list.d/
- 更新 apt repo 系统
apt update
- 降级mysql 常用软件包到 Ubuntu 版本。
- 使用 Synaptic GUI 包管理器或者
- 列出所有可用的源/版本
apt -a show mysql-common
并降级到 Ubuntu 软件包版本sudo apt install mysql-common=<VERSION>
或者 - 使用资质CLI 包管理器并尝试删除mysql 服务器包裹。资质交互式提供多种解决方案来解决冲突和依赖关系。拒绝所有说“不”的提议,直到你找到降级 mysql-common 至您想要的版本。
- 重新安装mysql 服务器包裹
apt install mysql-server