2

I am new to ubuntu. I am trying to uninstall mysql-server, while i'm doing it the purging process gets stuck at the line Renaming removed key_buffer and myisam-recover options (if present) and later on errors back saying E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. Can someone help me with this? I am using ubuntu 14.04lts. I tried doing what the error tells sudo dpkg --configure -a but it also errors back saying dpkg: error: dpkg status database is locked by another process.

3 Answers3

3

It looks that /var/cache/debconf/config.dat is locked by another process. Please remove it first by executing following steps.

service mysqld status 
ps aux | grep mysql
sudo service mysql stop
kill -9 mysql_pid
rm -rf /var/cache/debconf/config.dat

Then you can try to purge MySQL:

sudo apt-get purge mysql-server
David Foerster
  • 36,264
  • 56
  • 94
  • 147
Ramesh Chand
  • 7,274
  • 4
  • 33
  • 37
0

You probably want to stop the mysql service before purging it.

  1. You can see running services with:

    sudo service --status-all
    
  2. Then, you can stop the mysql service running

    sudo service mysql stop
    
  3. The service is now stopped, try again

    sudo apt-get purge mysql-server
    

Once done, you can try to re-install the mysql-server:

sudo apt-get update
sudo apt-get install mysql-server

While these steps should be enough, you can head to Cannot reinstall mysql-server after its purge and follow the provided steps to clean all your mysql setup.

  • I did the same thing, it returned an error Errors were encountered while processing: mysql-server-5.7 E: Sub-process /usr/bin/dpkg returned an error code (1). Maybe something to do withdpkg. – darshan krishnaiah Jul 25 '16 at 08:48
  • It's also showing while purging, debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable Setting up mysql-server-5.7 (5.7.13-0ubuntu0.16.04.2) ... debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable dpkg: error processing package mysql-server-5.7 (--configure): subprocess installed post-installation script returned error exit status 1 – darshan krishnaiah Jul 25 '16 at 08:52
  • First try to reboot the machine and try again. If still not working, try to remove the lock on dpkg dpkg: error: dpkg status database is locked by another process – ponsfrilus Jul 25 '16 at 08:55
  • Still not working! – darshan krishnaiah Jul 25 '16 at 10:14
0

I had this problem earlier, just finally fixed it. These are the steps that worked for me.

mysqldump --lock-all-tables -u root -p --all-databases > dump.sql
sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -r /etc/mysql
sudo rm -r /var/log/mysql
sudo apt-get install mysql-server
sudo mysql -u root -p < dump.sql
sudo service mysql restart

http://teachmelinux.com/2017/01/ubuntu-server-mysql-5-7-update-failure-fix/

David Foerster
  • 36,264
  • 56
  • 94
  • 147