我在 Ubuntu 17.04 上。
长话短说,在与 MariaDB 较量一番之后,我遵循了一些关于如何完全从我的家庭服务器中删除 MySQL 和 MariaDB 的可疑建议。现在我无法重新安装 mysql-server
。我在尝试时遇到此错误:
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!
所以我用 sudo service --status-all | 检查服务grep mysql
,果然...
[ - ] mysql
问题是,当我尝试 sudo service mysql status
时,我得到了
Unit mysql.service could not be found.
我真的很想在不进行全新安装的情况下安装 MySQL 并再次运行!感谢您的帮助。
最佳答案
看来我明白了。这没有任何意义,但我明白了。首先,我询问 dpkg
是否还有任何 mysql 包:
sudo dpkg --get-selections | grep mysql
没有任何结果,所以我检查了 MariaDB:
sudo dpkg --get-selections | grep maria
这显示了一些标记为卸载的软件包。
mariadb-client-10.1 deinstall
mariadb-common deinstall
mariadb-server-10.1 deinstall
因为 apt
没有合作,我用 dpkg -P
卸载了每一个。一旦我这样做并重新启动,mysql 不再列为服务并且 mysql-server
安装完美。希望这能为其他人节省一些时间。
关于mysql.service 丢失但显示在列表中 - 安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45494749/