Upgrading to MySQL 5.7.15 crashes on Ubuntu 16.04

This solution solved my problem:

  1. Back-up your database files with permissions:

    sudo cp -avt /your/backup/directory /var/lib/mysql /etc/mysql/my.cnf
    
  2. Delete mysql files:

    sudo rm -rv /etc/mysql 
    
  3. Remove MySQL completely via running:

    sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7 mysql-client-5.7 mysql-client-core-5.7
    

    Use of Synaptic is recommended.

  4. Create these folders:

    sudo mkdir -p /etc/mysql/conf.d
    

    mysql setup didn't do it automatically and I don't know why.

  5. Install MySQL again

    sudo apt install mysql-server
    

    I used sudo apt install lamp-server^ instead to install other dependencies for PHP development.

  6. Stop MySQL:

    sudo service mysql stop 
    
  7. Restore databases and files:

    sudo cp -a /your/backup/directory/mysql /var/lib   
    sudo cp /your/backup/directory/my.cnf /etc/mysql 
    
  8. Restart MySQL:

    sudo service mysql start 
    

An easy solution is to sudo killall mysqld while the apt-get operation is running.

The apt operation just kept on running without any errors after that(!)


I managed to fix this without having to purge everything. It seems the problem is that the sys schema database was never created, so here's the solution:

  1. Clone https://github.com/mysql/mysql-sys and cd into the cloned folder.
  2. In a terminal, run mysql -u root -p < ./sys_57.sql (or sys_56.sql, depending on your version)

Enjoy mysql_upgrade working again. I guess this probably was, an upgrading scripts mess-up.