安装 mysql-server 时出错-现在我无法安装任何软件包

安装 mysql-server 时出错-现在我无法安装任何软件包

我有 Ubuntu 20.04。mysql-server 安装失败。现在,当我运行时,sudo apt install -f我得到

$ sudo apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-8.0 (8.0.20-0ubuntu0.20.04.1) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package 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-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo dpkg ––configure –a也不起作用。我无法安装任何软件包。

问题不同于Ubuntu 20.04 上 mysql-server-8.0 安装问题因为我根本无法安装 mysql-server。他设法安装了它。但我的包管理器在安装时坏了,所以我现在无法安装或删除任何东西。

答案1

将系统启动到恢复模式并运行软件包它应该可以修复损坏的包裹。

答案2

我设法修复了包管理器问题,解决方案如下https://phoenixnap.com/kb/fix-sub-process-usr-bin-dpkg-returned-error-code-1

但我仍然无法运行mysql数据库

$ sudo systemctl start mysql
Failed to start mysql.service: Unit mysql.service not found.

$ sudo service mysqld start
Failed to start mysqld.service: Unit mysqld.service not found.

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

$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
$ sudo apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-8.0 (8.0.20-0ubuntu0.20.04.1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
MySQL has been frozen to prevent damage to your system. Please see /etc/mysql/FR
OZEN for help.

相关内容