dist 将 Ubuntu 升级到 Ubuntu 20.04 后 mysql 不起作用。我尝试删除它,我的目标是重新安装它。问题是我无法删除mysql-server-8.0:
sudo dpkg -r --force-all mysql-server-8.0
(Reading database ... 210243 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-8.0 (--remove):
installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
mysql-server-8.0
openhabvm@OpenHABVM:~$ sudo dpkg -r --force-all mysql-server-8.0
(Reading database ... 210243 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.28-0ubuntu0.20.04.3) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-8.0 (--remove):
installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
mysql-server-8.0
Run Code Online (Sandbox Code Playgroud)
错误信息表明该软件包的安装后脚本尝试启用MySQL的服务文件,但发现它已经关闭。您可以尝试按如下方式删除它:
sudo service mysqld start
sudo dpkg -r --force-all mysql-server-8.0
Run Code Online (Sandbox Code Playgroud)
如果这引发相同的错误,请按照以下方法之一进行操作。
用于强力净化包装。
由于删除软件包可能具有破坏性,因此请打印将删除的软件包的列表:
dpkg -l | awk '{print $2}' | grep -i mysql | grep -v lib
Run Code Online (Sandbox Code Playgroud)
检查是否有重要的包被删除。如果一切正常,请继续执行步骤 2。
清除包:
sudo dpkg -P --force-all $(dpkg -l | awk '{print $2}' | grep -i mysql | grep -v lib)
Run Code Online (Sandbox Code Playgroud)
这应该完全删除 MySQL。然后运行强制安装:
sudo apt -f install
Run Code Online (Sandbox Code Playgroud)
如果上述操作失败并出现相同的错误,请按照下列步骤操作:
sudo rm /var/lib/dpkg/info/mysql-server-8.0.postinst
Run Code Online (Sandbox Code Playgroud)
sudo dpkg -P --force-all $(dpkg -l | awk '{print $2}' | grep -i mysql | grep -v lib)
Run Code Online (Sandbox Code Playgroud)
运行强制安装:
sudo apt -f install
Run Code Online (Sandbox Code Playgroud)
清除软件包后,要重新安装它,请运行:
sudo apt update
sudo apt install mysql-server-8.0
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8887 次 |
| 最近记录: |