How to fix mysql-server depends on mysql-server-5.5; however: Package mysql-server 5.5 is not configured yet.
Recently while attempting to setup a new GitLab server on Ubuntu 14.04 using my iGitLab installer script, I ran into an issue when the script attempted to install MySQL (mysql-server) through APT. The specific error was dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-5.5; however: Package mysql-server-5.5 is not configured yet.
I tried removing MySQL and reinstalling, even attempted to configure through mysql-server-5.5, none of which worked, but luckily I did find a way to easily fix this …
When attempting to install MySQL through apt-get you are essentially installing from the Ubuntu/Debian package repository, and more than likely the error you’re getting is because you’re using an old image/iso of Ubuntu/Debian that is no longer compatible with the packages you are trying to install.
In my specific instance I created a new VPS from an Ubuntu 14.04 image, but it seems the latest package available from the Ubuntu Repository is not compatible with that version…but don’t worry, it’s very easy to fix.
Clean and remove MySQL and old/cached packages
First what you need to do is remove what has already been installed:
sudo apt-get clean
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
This will clean the repository cache, and remove anything that was installed and starts with mysql.
Upgrade to latest distribution version
Next you will need to upgrade the existing distribution to the latest version which is what the packages are tested against. Running this command will not upgrade to a new major version (like 14.04 to 14.10), but it will upgrade to the latest minor version (in my case it was 14.04 to 14.04.2). To upgrade to the latest major version (with Ubuntu) you would need to use do-release-upgrade.
sudo apt-get dist-upgrade
To give you a better understanding of what dist-upgrade does, here’s the description from the apt man page:
dist-upgrade in addition to performing the function of upgrade,
also intelligently handles changing dependencies with new versions
of packages; apt-get has a "smart" conflict resolution system, and
it will attempt to upgrade the most important packages at the
expense of less important ones if necessary. So, dist-upgrade
command may remove some packages. The /etc/apt/sources.list file
contains a list of locations from which to retrieve desired package
files. See also apt_preferences(5) for a mechanism for overriding
the general settings for individual packages.
Now that you have upgraded to the latest release of your current major distribution version you can go ahead and reinstall MySQL and everything should work correctly:
sudo apt-get install mysql-server
apt-get error examples:
Unpacking mysql-server-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.5.43-0ubuntu0.14.04.1_all.deb ...
Unpacking mysql-server (5.5.43-0ubuntu0.14.04.1) ...
Setting up mysql-server-core-5.5 (5.5.43-0ubuntu0.14.04.1) ...
Setting up mysql-server-5.5 (5.5.43-0ubuntu0.14.04.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 146: logger: command not found
ATTENTION: An error has occured. More info is in the syslog!
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 236: logger: command not found
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)