0

I am using Loki. Yesterday I got mysql server update and something went wrong with it, now I can't update my system nor can I install any package.

$ sudo apt 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.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mysql-server-5.7 (5.7.18-0ubuntu0.16.04.1) ...
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please note I did try starting mysql.service before the upgrade and also checked its status which shows 'action running' by systemctl. After running upgrade command I noticed mysql.service stopped on its own. Also I checked and did found that '/var/run/mysqld/mysqld.sock' existed before running upgrade.
I can't even uninstall mysql, so I am stuck in between.

3 Answers 3

1

Try forcibly reinstalling MySQL:

sudo apt remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean

sudo apt update
sudo apt install mysql-server
sudo mysql_install_db

Note that this will delete your databases!

1
  • I am getting error when running your very first command, error is paste at sprunge.us/GFZV
    – Alex Jones
    Commented Apr 28, 2017 at 17:23
0

After trial and error, I found the solution:

  • enable mysql service: systemctl enable mysql.service
  • and purge it again: sudo apt purge 'mysql*'
1
0

On my system some of the mysql service files were missing but the package maintainer versions were there, so I was able to fix it by doing the following:

sudo mv /etc/mysql/debian-start.dpkg-dist /etc/mysql/debian-start
sudo mv /etc/init.d/mysql.dpkg-dist /etc/init.d/mysql
sudo mv /etc/init/mysql.conf.dpkg-dist /etc/init/mysql.conf

This might explain why purging/reinstalling mysql fixes it since that would recreate those files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.