Ubuntu – 16.04 upgrade broke thesql-server


My overall upgrade went well, but I am left with a critically lingering issue of mysql-server not being able to install itself, and nothing I am trying gets it to work.

This is the error I see when trying to install/reinstall it:

Setting up mysql-server-5.7 (5.7.11-0ubuntu6) ...
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
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 its a followup error from a previous failure.
                   Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried completely removing it, though doing so attempts to install MariaDB because of dependencies (?). Any suggestions on what I can do to fix this would be most welcome.

Looks like I'm not the only one: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1573279

Best Answer

  • The instructions @andrew-beerman posted are on the right track, though they aren't quite clear to me and seem to recommend more than is necessary. I pieced together the answer from the above and a helpful post in the bug thread.

    These are the steps I took to correct this:

    1. Back up your my.cnf file in /etc/mysql and remove or rename it

      sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
    2. Remove the folder /etc/mysql/mysql.conf.d/ using

      sudo rm -r /etc/mysql/mysql.conf.d/
    3. Verify you don't have a my.cnf file stashed somewhere else (I did in my home dir!) or in /etc/alternatives/my.cnf use

      sudo find / -name my.cnf
    4. Backup and remove /etc/mysql/debian.cnf files (not sure if needed, but just in case)

      sudo mv /etc/mysql/debian.cnf /etc/mysql/debian.cnf.bak
      sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7
      sudo apt install mysql-server
    5. In case your syslog shows an error like "mysqld: Can't read dir of '/etc/mysql/conf.d/'" create a symbolic link:

      sudo ln -s /etc/mysql/mysql.conf.d /etc/mysql/conf.d

      Then the service should be able to start with sudo service mysql start.

    That got it working!