我在 Focal Fossa 上,安装了 mysql。我试图删除它并安装 mariadb。我试过了sudo apt-get remove mysql
,但当我这样做时,mysql -V
我得到了mysql Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
。然后我尝试了一下sudo apt-get purge mysql*
,它给了no matches found
我尝试了以下操作并得到同样的错误
sudo apt-get remove mysql-server
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.
/var/lib/dpkg/info/mysql-server-8.0.postinst: line 191: /usr/share/mysql-common /configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我尝试sudo dpkg -l | grep mysql
结果是
pi mysql-client-8.0 8.0.20-0ubuntu0.20.04.1 amd64 MySQL database client binaries
ii mysql-client-core-8.0 8.0.20-0ubuntu0.20.04.1 amd64 MySQL database core client binaries
ii mysql-common 5.8+1.0.5ubuntu2 all MySQL database common files, e.g. /etc/mysql/my.cnf
pF mysql-server-8.0 8.0.20-0ubuntu0.20.04.1 amd64 MySQL database server binaries and system database setup
pi mysql-server-core-8.0 8.0.20-0ubuntu0.20.04.1 amd64 MySQL database server binaries
ii php7.3-mysql 7.3.18-1+ubuntu20.04.1+deb.sury.org+1 amd64 MySQL module for PHP
ii php7.4-mysql
我尝试了sudo apt-remove mysql*
每一个,并且
Removing 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.
dpkg: error processing package mysql-server-8.0 (--remove):
installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
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
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我尝试时,sudo apt-get -f install
我得到了错误
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.
/var/lib/dpkg/info/mysql-server-8.0.postinst: line 191: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)
如果有人能帮忙我将非常感激。
`
答案1
对我有帮助的
sudo systemctl disable mysql
然后删除/清除或者其他什么。
sudo apt autoremove
完成了它的工作...完成了
答案2
您需要采取的操作:1. 获取所有与 mysql 相关的组件 2. 删除所有已安装的 mysql 组件 3. 清理安装目录(如果您需要旧数据,可以重命名该文件夹)
我觉得 yum 方法更好:
yum list installed | grep mysql
yum remove mysql-client mysql-server mysql-common mysql-devel
apt-get 方式:
sudo apt-get remove --purge mysql*
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove dbconfig-mysql
sudo apt-get dist-upgrade
删除数据和配置
rm -rf /var/lib/mysql/
rm -rf /etc/my.cnf
答案3
遇到了同样的问题并花了一整天的时间来解决...尝试:
dpkg -r mysql-server
dpkg -r mysql-client-8.0(your version of mysql)
dpkg -r mysql-server-8.0(your version of mysql)
dpkg -r mysql-common
dpkg -r mysql
好的...问题解决了...关键是当你卸载或清除 mysql 时,所有的依赖项都在那里,并且每个依赖项都相互依赖,因此你必须找到其他依赖项所依赖的第一个依赖项...
答案4
在我的例子中,一个损坏的 MySQL 实例仍在运行。我用以下命令终止了它:
sudo pkill mysql
sudo pkill mysqld
然后它就成功了。