Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql.service is missing but shows up on list - fails install

I'm on Ubuntu 17.04.

Long story short, after wrestling with MariaDB for a bit, I followed some questionable advice on how to completely remove both MySQL and MariaDB from my home server. Now I'm unable to reinstall mysql-server. I'm getting this error when I try:

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!

So I check for the service with sudo service --status-all | grep mysql, and sure enough...

[ - ]  mysql

Problem is, when I try sudo service mysql status, I get

Unit mysql.service could not be found.

I'd really like to get MySQL installed and working again without doing a clean install! Any help is appreciated.

like image 917
PortableStick Avatar asked Aug 03 '17 21:08

PortableStick


1 Answers

Looks like I got it. It doesn't make any sense, but I got it. First, I asked dpkg whether any mysql packages were still around:

sudo dpkg --get-selections | grep mysql

Nothing came up, so I checked for MariaDB:

sudo dpkg --get-selections | grep maria

This showed some packages marked for deinstallation.

mariadb-client-10.1                             deinstall
mariadb-common                                  deinstall
mariadb-server-10.1                             deinstall

Since apt wasn't cooperating, I uninstalled each one with dpkg -P. Once I did that and rebooted, mysql was no longer listed as a service and mysql-server installed perfectly. Hope this saves someone else some time.

like image 73
PortableStick Avatar answered Oct 04 '22 02:10

PortableStick