无法安装或删除MySQL


10

因此,今天我安装了MariaDB,以便可以通过phpmyadmin登录,显然它没有用,所以我将其删除,再次尝试了四次,但失败了。决定改为使用MySQL Server。删除MariaDB之后,我无法安装它。

这是我想做的事情和输出:

shavit@dedi:~$ sudo apt-get install mysql-server
[sudo] password for shavit:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.12-0ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
mysql_upgrade: Got error: 1524: Plugin 'unix_socket' is not loaded while connect                                                                                                                                                             ing to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates it's a follow-up er                                                                                                                                                             ror from a previous failure.
                            Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

shavit@dedi:~$ sudo apt-get remove mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaio1 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7
  mysql-server-core-5.7
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
  mysql-server
0 to upgrade, 0 to newly install, 1 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 159 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 35749 files and directories currently installed.)
Removing mysql-server (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
mysql_upgrade: Got error: 1524: Plugin 'unix_socket' is not loaded while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

我现在真的迷路了。.Googling告诉我应该跑步,apt-get install -f但是我得到的是:

shavit@dedi:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
mysql_upgrade: Got error: 1524: Plugin 'unix_socket' is not loaded while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
No apport report written because the error message indicates it's a follow-up error from a previous failure.
                                                                                                            dpkg: error processing package mysql-server-5.7 (--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.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

因此,我运行sudo apt-get autoremove并再次安装:

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu3) ...
No apport report written because the error message indicates it's a follow-up error from a previous failure.
                            Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

我是一个与Linux以及任何与Ubuntu有关的新手。有人可以伸出援助之手吗?非常感激!


也许尝试
亚历克斯·洛

@Alex我确实尝试过,但是Kaz Wolfe的解决方案有效
shavit

很高兴我们可以提供帮助。
Alex Lowe

Answers:


12

我认为您已安装MariaDB的事实导致了此问题。MariaDB设置的配置不能与原始MySQL完美配合。如果您要清除所有旧配置并从头开始设置所有内容,则应该可以使用。请注意,尽管这将删除您当前的数据库!备份所有重要数据。

尝试运行以下命令来重置和清除所有与MySQL相关的内容:

sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server

完成此操作后,请运行以下命令更新系统并“清理”程序包缓存。

sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install

然后,尝试重新安装MySQL Server:

sudo apt install mysql-server

1
运行第一个命令时,我得到以下输出:dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed-应该删除/etc/mysql吗?
shavit

@shavit是的,删除这些文件可能是一个好主意。
卡兹·沃尔夫

谢谢,我已经成功安装了MySQL Server!似乎您已经经历了最后一件事:我安装的全新MySQL服务器不允许我通过进行访问sudo mysql_secure_installation,当我拥有MariaDB时,它就可以工作。您对可能出什么问题有任何想法吗?
shavit

@shavit您应该在一个新问题中提出这个问题。在此处链接它,我将看到可以做什么。请确保包括任何收到的错误消息。
卡兹·沃尔夫

谢谢!我试图从几个小时内解决此问题。:)
BlueSuiter

7

如果您mariadb-server之前安装,可能会发生此错误mysql-server。要解决此错误,必须删除目录/var/lib/mysql*/etc/mysql*删除所有配置和依赖文件,然后再尝试安装MySQL。

sudo apt purge mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 mysql-server
sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && sudo apt -f install
sudo apt install mysql-server

这终于对我有用。谢谢。
Chinmay Nerurkar
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.