1

After problems with MySQL server that couldn't finish an update properly (5.7.24). I followed this answer. So basically, I can come back in a "stable" state when after running the following commands:

sudo apt update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autoclean
sudo dpkg --configure -a

All is working, MySQL is removed and no error are returned. (I could do the apt purge without error). There are no more /etc/mysql nor /var/lib/mysql directories. And the last dpkg doesn't find anything to do and returns nothing.

I reboot to be sure. But now, when I am doing :

sudo apt-get install mysql-server

I am getting this error:

dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Saying that is still not configured and there are dependency problems. So the install can't finish with success.

When running:

sudo dpkg-reconfigure mysql-server-5.7

It returns:

/usr/sbin/dpkg-reconfigure: mysql-server-5.7 est cassé ou partiellement installé

Can't be done because mysql-server-5.7 is broken or partially installed. So, is there a way to really return to a fresh state? I don't have to keep existing MySQL databases or configurations. Thanks.

3
  • 2
    Perhaps you need to fool update-alternatives by doing sudo update-alternatives --remove my.cnf. At least, that may get rid of the first error.
    – Jos
    Nov 8, 2018 at 17:29
  • To get a fresh state, you can remove all mysql* packages. First get installed packages that start with mysql with sudo apt list --installed | grep -i -E '^mysql. If you don't see anything that you need to keep, remove them all with sudo apt-get remove --purge mysql*. That command will also remove configs and dependencies installed related to mysql* packages. If you see something that you need to keep, remove them one by one or with a more restricted regex. After that you can try again.
    – bistoco
    Nov 9, 2018 at 7:00
  • @bistoco Yes I have done this. The purge works well. I don't have any MySQL package in my system anymore.
    – COil
    Nov 9, 2018 at 7:46

2 Answers 2

3

Ok I will answer to my question, thanks for the help, so what I have done after many try/error:

First, ensure you can run these commands without any error: (don't hesitate to reboot to avoid locks in apt)

sudo apt-get remove --purge mysql*
sudo apt update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autoclean
sudo dpkg --configure -a

Delete: (do backup before if you want but do no leave the files in these directories, even with .bak or .old extensions)

  • /etc/mysql
  • /var/lib/mysql

If you have an error mentioning alternatives, run: (replace my.cnf) by the file indicated in the error message)

sudo update-alternatives --remove my.cnf

Then reinstall:

sudo apt install mysql-server

Check now, if at least the mysql service is running:

sudo service mysql status

If still not OK, try to force reinstall:

sudo apt install mysql-server --reinstall

And reconfigure:

sudo dpkg-reconfigure mysql-server
1

Remove All

sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
sudo apt-get autoremove -y
sudo apt-get autoclean
rm -rf /etc/mysql

Greetings!

2
  • 2
    This does not seems to answer the question which is to reinstall mysql server. May 15, 2019 at 15:09
  • sudo apt install mysql-server May 15, 2019 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .