Home  |   About  |   Energy  |   Politics  |   Software  |   Music

13 June 2012

Getting MySQL back after another Ubuntu upgrade mess up

In my first look on Ubuntu 12.04 I got the impression that everything went fine with the upgrade from version 11.10. And indeed during a few weeks things went as smoothly as before. Until last week. I had to test an old project and got complains about the database connection. This database is managed by MySQL, hence I tried to access it with MySQL Administrator, which, lo and behold, wasn't installed any more. Though zombie icons still remained within the launcher and main menu, all packages related to MySQL had been disabled by the upgrade. There you go Ubuntu, you did it again!

My first reaction was simply to search for available packages, and indeed version 5.5 of MySQL is available in the repositories for this new Ubuntu release. I immediately proceeded to the install command, with it that starting a painful journey to get MySQL back on Ubuntu.

This was the result I got the first time I tried to install MySQL with apt-get:

$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
The following NEW packages will be installed:
  mysql-server mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 3 newly installed, 0 to remove and 26 not upgraded.
Need to get 14.9 MB of archives.
After this operation, 52.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://de.archive.ubuntu.com/ubuntu/ precise/main mysql-server-core-5.5 amd64 5.5.22-0ubuntu1 [6,022 kB]
Get:2 http://de.archive.ubuntu.com/ubuntu/ precise/main mysql-server-5.5 amd64 5.5.22-0ubuntu1 [8,816 kB]
Get:3 http://de.archive.ubuntu.com/ubuntu/ precise/main mysql-server all 5.5.22-0ubuntu1 [11.8 kB]
Fetched 14.9 MB in 2s (4,960 kB/s)       
Preconfiguring packages ...
Selecting previously unselected package mysql-server-core-5.5.
(Reading database ... 412919 files and directories currently installed.)
Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.22-0ubuntu1_amd64.deb) ...
Selecting previously unselected package mysql-server-5.5.
Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.22-0ubuntu1_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/mysql-server-5.5_5.5.22-0ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/mysql/plugin/ha_example.so', which is also in package libmysqlclient-dev 5.5.23-1~dotdeb.0
Selecting previously unselected package mysql-server.
Unpacking mysql-server (from .../mysql-server_5.5.22-0ubuntu1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
The first results browsing the internet pointed to an issue with the root password. Hence I tried to force a reconfiguration:
$ sudo dpkg-reconfigure mysql-server
/usr/sbin/dpkg-reconfigure: mysql-server is broken or not fully installed
Some more duckduckgoing brought up a reference to old packages interfering with the installation. That indeed was the case, note the old 5.1 package still there:
$ dpkg --get-selections | grep mysql
gambas2-gb-db-mysql    install
libdbd-mysql-perl    install
libmysqlclient-dev    install
libmysqlclient16    install
libmysqlclient18    install
libqt4-sql-mysql    install
mysql-admin     deinstall
mysql-client-5.5    install
mysql-client-core-5.5    install
mysql-common     install
mysql-query-browser    deinstall
mysql-server     install
mysql-server-5.1    deinstall
mysql-server-core-5.5    install
mysql-workbench     install
mysql-workbench-data    install
python-mysql.connector    install
So it seems the upgrade not only disabled MySQL, it didn't even cleaned up properly. I tried to send it all away:
$ sudo dpkg --purge mysql-admin mysql-query-browser mysql-server-5.1
(Reading database ... 413009 files and directories currently installed.)
Removing mysql-admin ...
Purging configuration files for mysql-admin ...
Removing mysql-query-browser ...
Purging configuration files for mysql-query-browser ...
Removing mysql-server-5.1 ...
Purging configuration files for mysql-server-5.1 ...
Processing triggers for ureadahead ...
After this I tried once again to install MySQL server, just to get the same error as above.

At this time my options ran out and I decided to hit the fora. I started with the Ubuntu Forum, where one of the largest Linux communities gathers, then also the MySQL Forum and another developers forum. Although I kept these threads alive with daily updates on my failed efforts to get MySQL back, I only got a single reply.

Another user with the same issue suggested a complete removal of all files related to MySQL plus the security package AppArmor. So I did, but still the same error would pop up when I tried to install MySQL. I also tried installing with aptitude, and then with alien using directly the rpm package supplied by Oracle, but still no luck.

Out of desperation I posted a question at AskUbuntu, a place that I don't particular like but that often shows up in web searches. Here things got much more interactive; within hours the problem was diagnosed as a conflict with packages installed from dotdeb.org. Though I wasn't very convinced at the time, this was probably correct; the problem was finding the offending package:
$ sudo cat /etc/apt/sources.list | grep dotdeb.org 
# deb php53.dotdeb.org stable all # disabled on upgrade to precise 
# deb-src php53.dotdeb.org stable all # disabled on upgrade to precise 

$ sudo aptitude search "?installed?origin(dotdeb.org)" 

$ sudo aptitude search "?installed?origin(php53.dotdeb.org)"
This morning, as I did another round through these various threads I opened on this subject, I noticed this tiny short comment at AskUbuntu suggesting the usage of the -f argument with the apt-get command:
sudo apt-get install -f mysql-server
And without complains MySQL installed. This was quite a surprise and an incredibly simple solution for what was becoming an insurmountable problem. I never used this argument before, didn't even knew about its existence. Here's what the man page says about it:
$ apt-get --help
  -f  Attempt to correct a system with broken dependencies in place 
Something to remember in the future.

One thing that goes different with apt-get install -f is that it doesn't prompt for the MySQL root password. This has to be made a posteriori, by editing the MySQL security file:
sudo pico /usr/bin/mysql_secure_installation
Then MySQL has to be restarted:
sudo /etc/init.d/mysql restart
With the Ubuntu 12.04 release the graphical applications MySQL Administrator and MySQL Query Browser were dropped and replaced by an all in one tool called MySQL Workbench. It looks quite promising, with facilities to manage several data bases, develop SQL queries and develop data bases with Entity-Relationship diagrams. Highly recommended, and this one you can simply add through the Software Centre.

The first conclusion I'd take from this episode is that AskUbuntu seems to be taking over the Ubuntu Forum in terms of responsiveness and expertise. In my view this is bad for two reasons: first of all because the AskUbuntu interface is quite bad, the mangling of answers and comments can make it quite hard to read and even more difficult to perceive from a time line perspective. Beyond that, the usual facilities to differentiate code from text or to insert hyperlinks are absent; in comments even ends of line aren't available, rendering them a cryptic soup of characters. And in second place the rise of AskUbuntu seems to be spliting the community, which though rather large, will always be stronger if kept together at a single experience exchange place.

A week passed from bumping in this issue to having MySQL running back again, with several working hours lost in between. Obviously this brings to question the Ubuntu upgrading policy. I already learn it the hard way that immediate upgrades usually have secondary consequences, hence I usually wait a few months after the official release to upgrade my system. This time I had an issue with battery lifetime that forced and early upgrade, otherwise I wouldn't have done it.

Ubuntu can't possibly retain this opaque package management policy if it really pretends to become a distribution for the wider masses. If an upgrade is degrading usability it must imperatively inform the user. If the process requires the removal of installed packages the user must be given the choice of either rolling back and cancel the upgrade, or continuing, knowing full well which applications or services are being disabled. Insisting on the current policy will undoubtedly cost users to Ubuntu, especially new comers, that while enjoying the system may undergo a shocking experience in their first upgrade.

No comments:

Post a Comment