Broken mysql, cannot uninstall or ugrade openemr

Running an upgrade by command line to Linux Mint, I got an error with processing mysql-server. I ran sudo dpkg --configure -a, the same error persisted. Output as follows below.

    robert@robert-ideacentre-AIO-520-22IKU ~ $ sudo apt-get upgrade
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
    3 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-server-5.7 (5.7.25-0ubuntu0.16.04.2) ...
    Checking if update is needed.
    Checking server version.
    Running queries to upgrade MySQL server.
    mysql_upgrade: [ERROR] 1010: Error dropping database (can't rmdir './performance_schema/', errno: 17)
    mysql_upgrade failed with exit status 5
    dpkg: error processing package mysql-server-5.7 (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up adobe-flashplugin (1:20190409.1-0ubuntu0.16.04.1) ...
    update-alternatives: error: alternative link /usr/lib/mozilla/plugins/flashplugin-alternative.so is already managed by mozilla-flashplugin.backup.20190407
    dpkg: error processing package adobe-flashplugin (--configure):
     subprocess installed post-installation script returned error exit status 2
    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
    No apport report written because the error message indicates it's a follow-up error from a previous failure.
                                Errors were encountered while processing:
     mysql-server-5.7
     adobe-flashplugin
     mysql-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    robert@robert-ideacentre-AIO-520-22IKU ~ $ sudo dpkg --configure -a
    Setting up mysql-server-5.7 (5.7.25-0ubuntu0.16.04.2) ...
    Checking if update is needed.
    Checking server version.
    Running queries to upgrade MySQL server.
    mysql_upgrade: [ERROR] 1010: Error dropping database (can't rmdir './performance_schema/', errno: 17)
    mysql_upgrade failed with exit status 5
    dpkg: error processing package mysql-server-5.7 (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up adobe-flashplugin (1:20190409.1-0ubuntu0.16.04.1) ...
    update-alternatives: error: alternative link /usr/lib/mozilla/plugins/flashplugin-alternative.so is already managed by mozilla-flashplugin.backup.20190407
    dpkg: error processing package adobe-flashplugin (--configure):
     subprocess installed post-installation script returned error exit status 2
    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
     adobe-flashplugin
     mysql-server
    robert@robert-ideacentre-AIO-520-22IKU ~ $ 

I then followed followed the most popular suggestion here:https://askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server

And came unstuck at purging mysql (see code below). During the process, it asked me if I was happy for openemr to be removed, and I said yes. However, it seems there was some problem with that. Now I can neither use, uninstall, or upgrade openemr. Any ideas on where to go next?

robert@robert-ideacentre-AIO-520-22IKU ~ $ sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaio1 libapache2-mod-php libbit-vector-perl libbytes-random-secure-perl
  libcarp-clan-perl libcrypt-random-seed-perl libdate-calc-perl
  libdbd-mysql-perl libdbi-perl libevent-core-2.0-5 libhttp-server-simple-perl
  libmath-random-isaac-perl libmysqlclient20 libtiff-tools
  libwww-mechanize-perl makepasswd mysql-common php php-curl php-gd
  php-gettext php-json php-mbstring php-mcrypt php-mysql php-soap php-zip
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
  mysql-client-5.7* mysql-client-core-5.7* mysql-server* mysql-server-5.7*
  mysql-server-core-5.7* openemr*
0 to upgrade, 0 to newly install, 6 to remove and 0 not to upgrade.
3 not fully installed or removed.
After this operation, 385 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 281528 files and directories currently installed.)
Removing openemr (5.0.0-2) ...
dpkg: error processing package openemr (--purge):
 subprocess installed pre-removal script returned error exit status 1
postinst asked to do abort-remove
dpkg: mysql-client-core-5.7: dependency problems, but removing anyway as you requested:
 mysql-client-5.7 depends on mysql-client-core-5.7.

Removing mysql-client-core-5.7 (5.7.25-0ubuntu0.16.04.2) ...
dpkg: mysql-server-core-5.7: dependency problems, but removing anyway as you requested:
 mysql-server-5.7 depends on mysql-server-core-5.7 (= 5.7.25-0ubuntu0.16.04.2).

Removing mysql-server-core-5.7 (5.7.25-0ubuntu0.16.04.2) ...
dpkg: mysql-server: dependency problems, but removing anyway as you requested:
 openemr depends on mysql-server | mariadb-server; however:
  Package mysql-server is to be removed.
  Package mariadb-server is not installed.

Removing mysql-server (5.7.25-0ubuntu0.16.04.2) ...
Removing mysql-server-5.7 (5.7.25-0ubuntu0.16.04.2) ...
Purging configuration files for mysql-server-5.7 (5.7.25-0ubuntu0.16.04.2) ...
Removing mysql-client-5.7 (5.7.25-0ubuntu0.16.04.2) ...
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
 openemr
E: Sub-process /usr/bin/dpkg returned an error code (1)
robert@robert-ideacentre-AIO-520-22IKU ~ $

OpenEMR Version
I’m using OpenEMR version 5.0.0 (6)

Browser:
I’m using: Chromiun

Operating System
I’m using: Linix Mint 18.3.

Logs
Did you check the logs? No, where can I find them?

Thank you.

Without knowing any more about the particular situation, if there was any important data in your EMR then the first concern would be that you made a backup prior to attempting the package upgrades.
From experience, Mint makes a great desktop, but not necessarily so good as a server platform.
The log files for the various services should be in /var/log. You will find sub directories there for apt, mysql, apache, etc.
This is normally the point where it would be time to start over, re-install all the server components, and reload database/data from the last backup. If there’s no current backup, it wouldn’t hurt to look in /var/lib/mysql, and see if any of the data files still remain after the package was purged, and if you do find any surviving databases and the accompanying innodb log/temp files, copy them to a safe location for potential later use. That’s all assuming that you had data in the EMR that you want to retain. If it was just a development system, then leave the mess behind and move on with a new, clean installation.

Thank you for your reply. In /var/log there is no sub directory for mysql. And I am unable to remove openemr. During the process I am asked to provide my mysql root password. The password of which I am 100% certain is not accepted, and I cannot proceed. I do have a backup.

Bump. Still not resolved. Any further help appreciated, as I just don’t know what to do.

PLEASE can somebody tell me how I can remove Openemr from my system (Linux Mint). To do this requires that I provide my msql root password, but this is not accepted because mysql is broken. There MUST be a way of doing this short of re-installing my whole system. Isn’t there? If not, please tell me. Thank you.

Surprised at the lack of response here (with the exception of ‘CG’).

A friend who was passing through and in ancient history worked with databases purged my system of openemr by using this command: sudo find / -iname ‘openemr*’ -exec rm -rf {} ;

He then restored mysql to an apparently healthy condition.

He then reinstalled openemr, but it cannot be accessed through the browser at localhost/openemr.

He has no more time left to help as he has to leave, so I am again asking for help here. As it is now a ‘different’ (albeit derived) problem, I am posting it as a separate thread. The thread is here: Cannot access newly installed OpenEMR at localhost/openemr

Thank you.