当前位置: 首页>>技术教程>>正文


无法安装mysql-server-5.5/以下软件包的依赖性不足

, ,

问题描述

我是这里的新手,请多多包涵。

我正在使用Ubuntu 14.04。

我尝试使用以下命令输入mysql:

mysql -u root -p

我收到以下消息:

The program mysql can be found on the following packages:
* mysql-client-core-5.5 
* mariadb-client-core-5.5 
* mysql-client-core-5.6 
* percona-xtrabd-cluster-client-5.5 

然后输入:

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

安装此程序后,我尝试使用以下方法再次连接到mysql:

mysql -u root -p

然后我得到了错误信息:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

在线搜索后,我发现我需要安装mysql服务器,因此我在以下命令中写道

sudo apt-get install mysql-server

然后我得到消息:

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-server : Depends: mysql-server-5.5 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

在过去的一个小时中,我一直在寻找解决方案,但是其他人也遇到了类似的错误,但是由于升级mysql而导致出现此错误,因此对我来说解决方案无效。

最佳办法

打开终端并输入:

sudo apt-get purge mysql-client-core-5.6
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt install mysql-client-core-5.5
sudo apt install mysql-server  

MySQL数据库核心客户端和MySQL Server软件包都将是相同的5.5版本。 MySQL客户端5.5和MySQL Server 5.5是Ubuntu 14.04中这些软件包的当前”best”版本,由软件包维护者确定。如果您想安装MySQL Client 5.6和MySQL Server 5.6,也可以在Ubuntu软件中心找到mysql-client-core-5.6和mysql-server-5.6软件包。重要的是,在任何情况下,客户端和服务器版本号均匹配。

在Ubuntu 16.04和18.04中,这两个软件包的名称分别为mysql-client-core-5.7和mysql-server-5.7。

次佳办法

以下命令解决了我的问题。

sudo aptitude install mysql-server

如果您的计算机中未安装aptitude,请首先使用以下命令安装aptitude。

sudo apt-get install aptitude

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/8757.html,未经允许,请勿转载。