How to get MySQL back on Ubuntu 12.04?

The upgrade to Ubuntu 12.04 delete MySQL and I need urgently to get it back. The problem is that I'm getting an error installing it, either with apt-get or aptitude:

Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.5_5.5.22-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've already tried different ways to install MySQL but without success, as reported in this thread at the Forum:

http://ubuntuforums.org/showthread.php?t=1998260

I believe I should file a bug, but following the instructions I thought better to ask here first.

Thank you for reading.


Solution 1:

If you read the log carefully, you see that the problem is that there is a package called libmysqlclient-dev with the version 5.5.23-1~dotdeb.0 which provides the file /usr/lib/mysql/plugin/ha_example.so. So, it seems that you had mysql installed from http://www.dotdeb.org. Try removing those packages first. You can find out which packages are from there using the following:

aptitude search "?installed?origin(packages.dotdeb.org)"

Remove them and then also remove the corresponding entry in your /etc/apt/sources.list file. Run apt-get update and then re-try installing your MySQL server.

Solution 2:

I finally managed to install mysql server following the tip by konrad, using sudo apt-get install -f.

Solution 3:

Got caught with this one as well, with dependency failures when trying to run "apt-get -f install" but I found a different way out:

:~# aptitude install mysql-server
The following packages will be upgraded:
  mysql-server 
1 packages upgraded, 0 newly installed, 0 to remove and 323 not upgraded.
Need to get 0 B/11.5 kB of archives. After unpacking 1,024 B will be used.
The following packages have unmet dependencies:
 mysql-server-5.5 : Depends: mysql-server-core-5.5 (= 5.5.34-0ubuntu0.12.04.1) but    5.5.37-0ubuntu0.12.10.1 is installed.
 The following actions will resolve these dependencies:

 Remove the following packages:
1)     mysql-server                
2)     mysql-server-5.5            



Accept this solution? [Y/n/q/?] Y
The following packages will be REMOVED:
  libdbd-mysql-perl{u} libdbi-perl{u} libmysqlclient18{u} 
  libnet-daemon-perl{u} libplrpc-perl{u} libterm-readkey-perl{u} 
  mysql-client-5.5{u} mysql-client-core-5.5{u} mysql-common{u} 
  mysql-server{a} mysql-server-5.5{a} 
0 packages upgraded, 0 newly installed, 11 to remove and 317 not upgraded.
Need to get 0 B of archives. After unpacking 76.9 MB will be freed.
Do you want to continue? [Y/n/?] y
(Reading database ... 215864 files and directories currently installed.)
Removing mysql-server ...
Removing mysql-server-5.5 ...
mysql stop/waiting
Removing mysql-client-5.5 ...
Removing libdbd-mysql-perl ...
Removing libdbi-perl ...
Removing libmysqlclient18:amd64 ...
Removing libplrpc-perl ...
Removing libnet-daemon-perl ...
Removing libterm-readkey-perl ...
Removing mysql-client-core-5.5 ...
Removing mysql-common ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Current status: 0 broken [-1], 317 updates [-7].
:~# apt-get install mysql-server

And, after that the install (e.g. would-be upgrade) went in cleanly.

Hope that helps others.