Ubuntu dpkg: error processing package mysql-community-server (--configure)

created at 02-23-2022 views: 47

problem

Ubuntu has dpkg: error processing package mysql-community-server (–configure): problem

Whether using sudo apt upgrade or sudo apt autoremove the problem remains.

sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  libmysqlclient-dev mysql-client mysql-server mysql-testsuite
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-community-server (5.7.37-1ubuntu18.04) ...
update-alternatives: error: alternative path /etc/mysql/mysql.cnf doesn't exist
dpkg: error processing package mysql-community-server (--configure):
 installed mysql-community-server package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= 5.7.37-1ubuntu18.04); however:
  Package mysql-community-server is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-test:No apport report written because the error message indicates its a followup error from a previous failure.

 mysql-community-test depends on mysql-community-server (= 5.7.37-1ubuntu18.04); however:
  Package mysql-community-server is not configured yet.

dpkg: error processing package mysql-community-test (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-testsuite:No apport report written because the error message indicates its a followup error from a previous failure.

 mysql-testsuite depends on mysql-community-test (= 5.7.37-1ubuntu18.04); however:
  Package mysql-community-test is not configured yet.

dpkg: error processing package mysql-testsuite (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already

solution

The solution is as follows:

try the following command

sudo apt-get install -f

to see if it fixes broken dependencies.

If that fails, clean up the MySQL server:

  sudo apt-get purge mysql-community-server mysql-community-server

Then clean and update:

  sudo apt-get autoclean && sudo apt-get clean && sudo apt-get update

Do general upgrades:

  sudo apt-get upgrade

Now try to reinstall:

sudo apt-get install mysql-server and mysql-community-server

If you do this from the root prompt, the leading sudo command will not be booted.

created at:02-23-2022
edited at: 02-23-2022: