Stuck on Package mysql-server-5.7 is not configured yet error when upgrading mysql? Let's fix it.

I got this error while upgrading mysql in WSL Ubuntu (but this seems to happen on other debian based distros as well):

Package mysql-server-5.7 is not configured yet.

mysql config error

The fixes I found with google were complicated, in some cases suggested to remove the existing database or config files. None of that is necessary.

The issue is that the mysql service is not running at the point when the post installation script is trying to upgrade the database.

To fix, we'll hack the postinst script. The script is /var/lib/dpkg/info/mysql-server-5.7.postinst. Let's edit the file (as root):

sudo vi /var/lib/dpkg/info/mysql-server-5.7.postinst

Look for the line where mysql_upgrade is called:

mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$? 

mysql postinst before

Insert a line to start the mysql service above it (both start and restart work):

service mysql restart

mysql postinst after

Save, then run the configuration step again using dpkg:

sudo dpkg --configure -a

The mysql upgrade should now run without the error:

mysql config fixed

Add a comment

Previous Post