Broken MySQL, can't reinstall, can't remove

Broken MySQL, can't reinstall, can't remove

So I had some problems getting Mariadb working in Mint 20 so I removed it and tried to install MySQL and now MySQL doesn't start, can't be removed and can't be reinstalled. Any help / advice would be greatly appreciated:

Reinstall:

$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed
  mysql-server
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
Need to get 0 B/9,552 B of archives.
After this operation, 111 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 395515 files and directories currently installed.)
Preparing to unpack .../mysql-server_8.0.21-0ubuntu0.20.04.4_all.deb ...
Unpacking mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 9174
Skipping profile in /etc/apparmor.d/disable: usr.sbin.mysqld
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 processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Remove:

$ sudo apt remove --purge mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  mysql-server*
0 to upgrade, 0 to newly install, 1 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 111 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 395518 files and directories currently installed.)
Removing mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 9860
Skipping profile in /etc/apparmor.d/disable: usr.sbin.mysqld
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 processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)

Autoclean:

$ sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 10673
Skipping profile in /etc/apparmor.d/disable: usr.sbin.mysqld
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 processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

OK, finally managed to get it sorted after stumbling on this:

https://stackoverflow.com/questions/45494749/mysql-service-is-missing-but-shows-up-on-list-fails-install#45495298

Like that guy I had a list of mariadb packages marked for removal. Unlike that guy I also had a bunch of mysql-server packages installed too.

I removed all of them (mysql and mariadb) with dpkg --purge, rebooted, reinstalled mariadb-server and now all is good.

相关内容