Installing mysql on Ubuntu

Way harder than I thought

Let's start with this: I'm not so Linux-familiar and when I run into problems I search in Google.
That's what happened the last night.
I decided to install mysql onto my VPS. I checked that I should just run

sudo apt-get install mysql-server

Wrong!

What went wrong

Of course I tried several times to install whis with no effect. I started searching the Internet for information why it gives me

dpkg: error processing mysql-server (--configure)

All the information didn't help me. I tried everything that I found so I updated my system and whatever you can think of. No luck. The system runs Ubuntu 12.10 x64 from DigitalOcean.
I tried purging, cleaning, autoremove, autoclean, update, upgrade, configure... So it became clear that I should do something different and with another mysql version because with the default - 5.5 - is not going to happen.

The solution

1. First download the .deb package from http://downloads.mysql.com/archives/community/. Select Debian Linux and whichever version you want, then download it. The mysql website is so messy that I lost a couple of minutes to find where this download section is.

2. If you have already tried installing be sure you have removed the mysql-server, directories and then cleaned.

sudo apt-get purge mysql-server mysql-client mysql-common mysql-client-5.5 mysql-server-5.5
sudo rm -rf /var/lib/mysql /etc/mysql ~/.mysql
sudo apt-get autoclean
sudo apt-get autoremove

These may be slight different for you if the version is not 5.5.

3. When everything is clear I ran these:

sudo dpkg -i mysql-5.6.16-debian6.0-x86_64.deb 
sudo apt-get install mysql-server

Of course if your package version is different you should change it in the first line.

Finally! The mysql is running.

I lost 3 hours but managed to make it work. Maybe the default mysql-server has something preventing it from simple install.

Good luck!

Lucky giraffe