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


无法在Ubuntu中安装mysql-server

, ,

问题描述

我无法在ubuntu 9.10服务器计算机上安装mysql-server。使用apt-get安装mysql-server时,输出为:

# apt-get install mysql-server

Reading package lists... Done
Building dependency tree
Reading state information... Done

mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 120 not upgraded.
2 not fully installed or removed.

After this operation, 0B of additional disk space will be used.
Setting up mysql-server-5.1 (5.1.37-1ubuntu5.4) ...
* Stopping MySQL database server 
    Mysqld    [ OK ]
* Starting MySQL database server 
mysqld [fail]

invoke-rc.d: initscript mysql, action "start" failed.

dpkg: error processing mysql-server-5.1 (--configure):

subprocess installed post-installation script returned error exit status 1

dpkg: dependency problems prevent configuration of mysql-server:

mysql-server depends on mysql-server-5.1; however:
Package mysql-server-5.1 is not configured yet.

dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured

No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.1
mysql-server  
E: Sub-process /usr/bin/dpkg returned an error code (1)

我无法在任何地方找到令人满意的解决方案。许多站点要求重新安装它,但无法正常工作。

任何帮助将不胜感激。

谢谢..

最佳方法

这为我工作:

apt-get purge mysql-server
apt-get purge mysql-common
rm -rf /var/log/mysql
rm -rf /var/log/mysql.*
rm -rf /var/lib/mysql
rm -rf /etc/mysql
# and then:
apt-get install mysql-server --fix-missing --fix-broken

虽然它也会删除对mysql的所有依赖关系。

而且它将删除现有数据库,先备份!

Source

次佳方法

一些建议:

  • 显而易见,请确保您以root用户身份运行。

  • 尝试执行apt-get删除mysql。

  • 然后尝试进行apt-get清除(您可能需要apt-get清除mysql,有时智能可能会很挑剔)。

  • 始终检查您的日志。他们很可能会为几乎所有问题提供答案。

  • 另外,请尝试进行apt-get清除缓存和apt-get清除。然后尝试再次安装。

或尝试我在Google上找到的此解决方案:

The mysql-server-5.1 package tries to start MySQL after the package is installed, which fails. The first thing you need to do is finish the installation process cleanly. There are several ways to do this:

either fix your MySQL configuration, check that /etc/init.d/mysql-server works, and launch dpkg –configure -a to finish the installation process ; or edit /var/lib/dpkg/info/mysql-server-5.1.postinst and remove the part where it starts the server (probably calling /etc/init.d/mysql-server start or so), then launch dpkg –configure -a to finish the installation process and then fix your configuration.

参考资料

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