I recently upgraded from 12.10 to 16.04 on my server. After upgrading (which appears to have gone fine), I was unable to login to my mysql server. As such, I uninstalled the server, and reinstalled using:

apt-get remove mysql-server
apt-get install mysql-server

However, now it always seems to give me:

Renaming removed key_buffer and myisam-recover options (if present)
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
insserv: warning: script 'screen-cleanup' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `screen-cleanup'
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
Setting up mysql-client (5.7.16-0ubuntu0.16.04.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
Processing triggers for systemd (229-4ubuntu11) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:

I tried stopping the service, uninstalling, purging, and even removing /etc/mysql and /var/lib/mysql (after backing up, of course).

I'm at a complete loss as to why this is happening now. I can't seem to recover my database data. I've noticed that whenever I do this uninstall/reinstall procedure, it's not asking me for a mysql password, so I wonder if it's not completely uninstalled.

  • Even trying to uninstall gives this error. It seems the package is in a weird state.
    – jwir3
    Oct 27, 2016 at 20:49

2 Answers 2


To remove all config files use

apt-get purge mysql-server\*
rm -rf /etc/my.cnf /etc/mysql

If you want to delete all databases as well, you need to delete the directory /var/lib/mysql, too.


To add to the other answers, don't forget to also do an autoremove and autoclean. Try these steps:

sudo apt-get remove --purge mysql*
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove dbconfig-mysql

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.