Ubuntu – Unable to install thesql-server in Ubuntu

aptMySQLUbuntu

I am unable to install mysql-server on my ubuntu 9.10 server machine.
When using apt-get install mysql-server the output is :

# apt-get install mysql-server

Reading package lists... Done
Building dependency tree
Reading state information... Done

mysql-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 120 not upgraded.
2 not fully installed or removed.

After this operation, 0B of additional disk space will be used.
Setting up mysql-server-5.1 (5.1.37-1ubuntu5.4) ...
* Stopping MySQL database server 
    Mysqld    [ OK ]
* Starting MySQL database server 
mysqld [fail]

invoke-rc.d: initscript mysql, action "start" failed.

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

subprocess installed post-installation script returned error exit status 1

dpkg: dependency problems prevent configuration of mysql-server:

mysql-server depends on mysql-server-5.1; however:
Package mysql-server-5.1 is not configured yet.

dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured

No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.1
mysql-server  
E: Sub-process /usr/bin/dpkg returned an error code (1)

I cant find a satisfactory solution to this problem anywhere.
Many sites tell to reinstall it but its not working.

Any help will be appreciated.

Thank you..

Best Answer

This worked for me:

apt-get purge mysql-server
apt-get purge mysql-common
rm -rf /var/log/mysql
rm -rf /var/log/mysql.*
rm -rf /var/lib/mysql
rm -rf /etc/mysql
# and then:
apt-get install mysql-server --fix-missing --fix-broken

Although it will also remove all dependencies on mysql.

And it will also delete existing databases, backup first!

Source.