升级到 Ubuntu 16.04 后,我注意到 mysql 出现了令人难以置信的错误。确信,这是一个损坏的设置,我尝试运行 mysql 的清除。这似乎并没有删除所有内容,所以我尝试自己做:
sudo rm -r /etc/mysql
sudo rm -r /usr/share/mysql-workbench
sudo rm -r /usr/share/mysql
sudo rm -r /usr/share/mysql-common
这是一个错误。永远不要尝试这样做。现在mysql甚至无法正确安装。我试过重新安装依赖项:
sudo apt-get install --reinstall $(apt-cache depends mysql-server | grep -Po 'Depends:\s+\K[^ ]+$' | tr '\n' ' ' )
和包裹本身:
sudo apt install mysql-workbench mysql-server --reinstall
但是我得到了各种神秘的错误,例如:
sudo apt-get install --reinstall mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 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.
E: Internal Error, No file name for mysql-server:amd64
并卸载
sudo apt-get remove mysql-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libmysqlclient20 : Depends: mysql-common (>= 5.5) but it is not going to be installed
mariadb-client-core-10.0 : Depends: mariadb-common (>= 10.0.24-7) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
或者如果我重新配置
sudo dpkg --configure -a
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
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
或者如果我强制安装:
sudo apt-get -f install
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-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
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 its a followup 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)
或者,如果我进行清除:
sudo apt-get -f purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
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 ... 348226 files and directories currently installed.)
Removing mysql-server (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 112: /usr/share/mysql-common/configure-symlinks: No such file or directory
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)
apt 无法从部分安装中恢复吗?我必须重新安装操作系统吗?
执行以下操作以清除损坏的包:
之后重新安装它:
感谢@Videonauth
然后运行:
如果有任何失败,只需运行
sudo dpkg -r <failedpackage>
,如果失败,只需删除依赖它的包。如果你重复,最终 apt-get 将再次工作。另请参阅dpkg 和 aptitude/apt-get 有什么区别?
尝试这个,
运行此命令以清除 mysql,将 5.7 版本替换为您安装的版本
运行它来清理和更新包
最后安装mysql
这对我有用。
mysql
如上所示清除后,您必须以这种方式安装mysql:以这种方式安装时,不会出现安装错误。
我不知道确切的原因,但所有这些方法都对我不起作用。就我而言,纠正问题的程序是:
并重新启动!
终于,我能跑了
sudo apt-get install mysql-server
!这对我有用
然后之后我再次安装了mysql
sudo apt-get install mysql-server
现在它工作正常。我也遇到了这些错误,浪费了很多时间。运行这些命令
我在这个网站上找到 了解决方案 解决方案的来源
命令sudo dpkg -r对我不起作用..
我曾经
sudo apt-get purge mysql-*
卸载所有相关页面然后重新安装它们这为我修复了它(MySQL 8.0 - Ubuntu 20.04)
但是包“mysql-client-core-8.0”没有卸载,所以......
没有更多的错误!