在 Ubuntu 16.04 服务器上相对默认安装 LEMP(w/mysql)。
按照 MariaDB 网站上的说明进行安装时:https://downloads.mariadb.org/mariadb/repositories/#mirror=digitalocean-nyc&distro=Ubuntu&distro_release=xenial--ubuntu_xenial&version=10.1除最后一步实际尝试安装外,所有步骤均有效。
$ sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
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: mariadb-server :
Depends: mariadb-server-10.1 (= 10.1.17+maria-1~xenial) but it is not
going to be installed
E: Unable to correct problems, you have held broken packages.
我发现这个网站上的其他人多年来也遇到过类似的错误,但大多数人都没有答案,或者答案只针对他们的版本。
更新在运行注释中的命令后,最后的安装步骤成功了,但是在输入 root 密码后,它提到发生了错误:
设置 MariaDB 管理用户的密码时出错。这可能是因为该帐户已有密码,或者与 MariaDB 服务器的通信出现问题。
您应该在安装软件包后检查该帐户的密码。请阅读 /usr/share/doc/mariadb-server-10.1/README.Debian 文件以获取更多信息。
单击确定后,它继续安装许多包,但随后在此处显示错误:
Installing new version of config file /etc/mysql/debian-start ...
2016-09-27 14:15:23 139954230032640 [Note] /usr/sbin/mysqld (mysqld 10.1.17-MariaDB-1~xenial) starting as process 8339 ...
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mariadb-server-10.1 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mariadb-server:
mariadb-server depends on mariadb-server-10.1 (= 10.1.17+maria-1~xenial); however:
Package mariadb-server-10.1 is not configured yet.
dpkg: error processing package mariadb-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu8) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mariadb-server-10.1
mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
您可以尝试使用“sudo apt-mark showhold”来查看哪些软件包可能被“保留”(“您保留了损坏的软件包”)。然后,您可以使用“sudo apt-mark unhold package-name”来“取消保留”它们。
通常“sudo apt-get update”也是一个好主意,以确保你的本地 apt 缓存知道什么可用,什么不可用。
答案2
每次遇到这个问题我都会考虑刷新我的 sources.list 文件..:
sudo apt-get autoclean
删除 sources.list 文件并创建新的 sources.list...
sudo rm /etc/apt/sources.list
然后输入
sudo software-properties-gtk
这将打开 software-properties-gtk 并自动创建一个 newsources.list。
然后将服务器更改为美国或您选择的任何其他服务器。您必须从新对话框中启用存储库才能创建新的 sources.list。
勾选所有框然后单击“恢复”,再单击“关闭”。
需要恢复默认存储库
sudo apt-get update && sudo apt-get dist-upgrade -y
(最好在安装之前备份此文件,以便在发生此类情况时进行恢复)
现在安装任何东西! sudo apt-get install mariadb-server