尝试清除 MySQL 失败

尝试清除 MySQL 失败

我目前正在努力解决一些 mysql 问题。

我现在有一段时间不能使用 apt-get 了,因为它总是卡在那一行Setting up mysql-server-5.6 (5.6.27-0ubuntu0.15.04.1) ...,不让我做任何事情。所以我试着重新安装 mysql,清除它。虽然我能够删除,mysql-servermysql-client最终还是无法清除mysql-common。显然,我设法破坏了一些东西,但此时我该如何让我的系统恢复运行呢?

...:~# apt-get purge mysql-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  mysql-common*
0 upgraded, 0 newly installed, 1 to remove and 5 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 423600 files and directories currently installed.)
Removing mysql-common (5.6.27-0ubuntu0.15.04.1) ...
Purging configuration files for mysql-common (5.6.27-0ubuntu0.15.04.1) ...
update-alternatives: error: /var/lib/dpkg/alternatives/my.cnf corrupt: invalid status
dpkg: error processing package mysql-common (--purge):
 subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
 mysql-common
E: Sub-process /usr/bin/dpkg returned an error code (1)

-

...# sudo dpkg -P --force-all mysql-common
(Reading database ... 424733 files and directories currently installed.)
Removing mysql-common (5.6.27-0ubuntu0.15.04.1) ...
Purging configuration files for mysql-common (5.6.27-0ubuntu0.15.04.1) ...
update-alternatives: error: no alternatives for my.cnf
dpkg: error processing package mysql-common (--purge):
 subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
 mysql-common

-

...:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:   vivid

我的目标是让它恢复并再次运行(mysql)。

答案1

在说了几句话之后聊天,解决方案如下:

sudo rm /etc/alternatives/my.cnf
sudo ln -s /etc/mysql/mysql.cnf /etc/alternatives/my.cnf

为什么?文件/etc/alternatives/my.cnf 必须一个链接,没有其他内容。

这是错误信息:

$ sudo update-alternatives --config my.cnf 
update-alternatives: warning: alternative /etc/mysql/mysql.cnf (part of link group my.cnf) doesn't exist; removing from list of alternatives
update-alternatives: error: unable to read link `/etc/alternatives/my.cnf': Invalid argument

相关内容