Last night I tried to upgrade my Ubuntu OS and MySQL 5.7.15 was one of the changes. It seems upgrading is successfull because mysql is propely working, but installation proccess has stop working with this message:

This installation of MySQL is already upgraded to 5.7.15, 
use --force if you still need to run mysql_upgrade

I can't cancel the installation proccess in reqular way and just have to kill it. So it may cause some problem and also for every other installation (in the future) it tries to do it again.

How to prevent this upgrade or solve it?


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 
  • 1
    dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: mysql-server-5.7
    – stephen
    Jan 20 '17 at 11:58
  • Key thing is removing: sudo rm /var/cache/debconf/config.dat, sudo rm /var/cache/debconf/passwords.dat and sudo rm /var/cache/debconf/templates.dat. Then purge everything. Then do a system reboot.
    – stephen
    Jan 20 '17 at 12:57
  • I had same problem and solved it with this procedure. I recommend a system reboot after purging MySQL. It seems that this prevents the issue reported by Stevie.
    – Tsutomu
    Apr 18 '17 at 0:36
  • Error come backs with the next MySQL update :( Jul 30 '20 at 13:29

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(!)

  • This actually worked. Have my upvote
    – easwee
    Sep 7 '20 at 19:16
  • Probably best answer. Oct 1 '20 at 18:23
  • Works perfectly
    – JayJay
    Jan 30 at 4:59

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.

  • Yes it is an issue with upgrading databases. Unfortunately I can't test your solution anymore to see if it's working or not.
    – Omid
    Apr 11 '17 at 10:11
  • I tried this solution on my mysql 5.7.22 installation that was reporting "This installation of MySQL is already upgraded to 5.7.22, use --force if you still need to run mysql_upgrade" and it worked like a charm
    – henrik
    Oct 31 '18 at 21:50

If your root@localhost account has no password then there is a bug in the postinstall process as stated here (see particularly the last comment of the thread)

  • purge all TMP* files in /var/lib/mysql-files
  • edit the file /var/lib/dpkg/info/mysql-server-5.7.postinst and comment (using #) the line 370 :

    echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH 'auth_socket';" >> "$initfile"

  • run again sudo dpkg --configure -a

  • Oh dear me ! <3 You saved my life :p Note for posterity : you may want to prevent further mysql update (which will fail the same way) using apt-mark hold mysql-server-5.7
    – Gab
    Aug 5 '19 at 11:41
  • This saved my day! Running Ubuntu 18.x via Vagrant, and indeed: No password for root, so it was stuck.
    – Ugur
    Jan 15 at 17:07
  • Worked perfectly! thanks for the insight!
    – Maxtrix
    Jan 26 at 16:03

I had this issue too. Every time I started apt get and installed the process would hang after or during the DB update. None of the other solutions here worked.

In the end I purged

sudo apt purge mysql-server mysql-server-5.7

And followed the manual install from the instructions for mysql here

I then overwrote the data directory with my old data

sudo cp -Rfv /var/lib/mysql /usr/local/mysql/data

and finally added a systemd service like this


Description=MySQL Server

ExecStartPre=/bin/mkdir -p /var/run/mysqld
ExecStartPre=/bin/chown mysql:mysql -R /var/run/mysqld
ExecStart=/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306


Then ran

# systemctl daemon-reload
# systemctl enable mysql
# systemctl start mysql

Then everything seemed to be working as before and mysql was not breaking system updates

The downside, of course, is that I'll need to do manual updates in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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