I'm using Bash for Windows and I had some troubles getting MySQL to work at some point.Now it's working fine, however it looks like there are some remnant of the installation process in apt-get. Every time I try to install any package (whether related to mysql or not), it's running mysql_upgrade and fails.However it doesn't need to run this since MySQL works fine. Is there any way to get apt-get to stop doing this?For information this is how it looks:Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following package was automatically installed and is no longer required:  snap-confineUse 'sudo apt autoremove' to remove it.The following additional packages will be installed:  libzip4The following NEW packages will be installed:  libzip4 php7.1-zip0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.2 not fully installed or removed.Need to get 59.8 kB of archives.After this operation, 191 kB of additional disk space will be used.Do you want to continue? [Y/n]Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 libzip4 amd64 1.1.2-1.1+deb.sury.org~xenial+1 [40.1 kB]Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.1-zip amd64 7.1.4-1+deb.sury.org~xenial+1 [19.8 kB]Fetched 59.8 kB in 0s (260 kB/s)Selecting previously unselected package libzip4:amd64.(Reading database ... 57661 files and directories currently installed.)Preparing to unpack .../libzip4_1.1.2-1.1+deb.sury.org~xenial+1_amd64.deb ...Unpacking libzip4:amd64 (1.1.2-1.1+deb.sury.org~xenial+1) ...............................................................................................................................................................................]Selecting previously unselected package php7.1-zip.#####.................................................................................................................................................................................]Preparing to unpack .../php7.1-zip_7.1.4-1+deb.sury.org~xenial+1_amd64.deb ...Unpacking php7.1-zip (7.1.4-1+deb.sury.org~xenial+1) ...#############....................................................................................................................................................................]Processing triggers for libc-bin (2.23-0ubuntu7) ...##########################################...........................................................................................................................................]Processing triggers for libapache2-mod-php7.1 (7.1.4-1+deb.sury.org~xenial+1) ...Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...invoke-rc.d: could not determine current runlevel * Stopping MySQL database server mysqld                                                                                                                                                                                              [ OK ]invoke-rc.d: could not determine current runlevelinvoke-rc.d: could not determine current runlevel * Stopping MySQL database server mysqld                                                                                                                                                                                              [ OK ]invoke-rc.d: could not determine current runlevelmysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL serverUpgrade process encountered error and will not continue.mysql_upgrade failed with exit status 11dpkg: error processing package mysql-server-5.7 (--configure): subprocess installed post-installation script returned error exit status 1dpkg: 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 unconfiguredSetting up libzip4:amd64 (1.1.2-1.1+deb.sury.org~xenial+1) ...No apport report written because the error message indicates its a followup error from a previous failure.Progress: [ 47%] [########################################################################################Setting up php7.1-zip (7.1.4-1+deb.sury.org~xenial+1) .........................................................................]Progress: [ 52%] [##################################################################################################################.....................................................................................................]Creating config file /etc/php/7.1/mods-available/zip.ini with new versionProcessing triggers for libc-bin (2.23-0ubuntu7) ...#############################################################################################........................................................................................]Processing triggers for libapache2-mod-php7.1 (7.1.4-1+deb.sury.org~xenial+1) ...Errors were encountered while processing: mysql-server-5.7 mysql-serverE: Sub-process /usr/bin/dpkg returned an error code (1)
apt-get keeps trying to install package that's already installed
apt;mysql
The mysql-server-5.7 package is not properly installed. The files have been unpacked, but something went wrong while finishing to set up the package. What went wrong doesn't affect you that you know of but the package manager can't know that.The error that's preventing the installation from completing ismysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL serverI'm not familiar with MySQL, so I don't know how to resolve this. It is a pretty generic error that could have many causes. You may have an unusual configuration of MySQL that Debian's scripts can't cope with.The script that's running and failing at that point is /var/lib/dpkg/info/mysql-server-5.7.postinst. If you want to debug why it's failing, change the line set -e to set -ex at the beginning of the script, and you'll get a trace of the commands that this script executes.To try running the upgrade again, runsudo dpkg --configure -aorsudo apt-get -f installThe package manager will be satisfied when /var/lib/dpkg/info/mysql-server-5.7.postinst runs successfully (i.e. with exit status 0). You may be tempted to force it to exit with a success status without doing its job, but be careful: if you mess up, you may corrupt your database.