重新安装后 MySQL 出现错误

重新安装后 MySQL 出现错误

起初,我想重新安装 MySQL 来修复 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)命令等的问题apt-get purge mysql-serverapt-get purge mysql-client并手动删除等文件夹/var/lib/mysql//etc/mysql/

在使用 安装新的 MySQL 包时apt-get install mysql-server,我遇到了以下问题:

Preparing to unpack .../mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb (--unpack):
new mysql-server-8.0 package pre-installation script subprocess returned error exit status 1
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_8.0.27-0ubuntu0.20.04.1_all.deb ...
Unpacking mysql-server (8.0.27-0ubuntu0.20.04.1) ...
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-8.0_8.0.27-0ubuntu0.20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我试图停止 MySQL,但由于与上述相同的问题,我得到的只是Failed to stop mysql.service: Unit mysql.service not loaded.命令apt-get --fix-broken install也不起作用。

mysql命令有效,但它会导致与一开始相同的问题。

答案1

打开错误关于此: https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1897381

联系:https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1612517

固定的: 我知道这是老问题了,但是这是我的情况所修复的:

  • 检查是否有任何损坏的服务链接 ( /etc/systemd/system/mysql.service)
  • 删除所有 MariaDB 内容 ( sudo dpkg --get-selections | grep maria)
  • 找到详细信息这里

相关内容