In my attempt to move the MySQL datadir I have a messed up MySQL installation. Here’s how I’ve completely removed MySQL 5.1 from Ubuntu 10.x. i have a messed up installation and need to completely remove MySQL and re-install it. Warning, this will delete *everything* associated with MySQL on ubuntu! It does give you a fresh install!

using apt:
apt-get –purge remove mysql-server
apt-get –purge remove mysql-client
apt-get –purge remove mysql-common

apt-get autoremove
apt-get autoclean

using aptitude (some people claim aptitude does a better job of removing dependencies):
aptitude remove mysql-client
aptitude remove mysql-server
aptitude remove mysql-common

see if anything depends on the installed packages
apt-cache rdepends mysql-server
apt-cache rdepends mysql-client

if you’ve changed apparmor settings change them back inside here:
pico /etc/apparmor.d/usr.sbin.mysqld

delete preferences(the next find command will delete everything):
rm -rf /etc/mysql

find all files with “mysql” on / and delete them:
find / -iname ‘mysql*’ -exec rm -rf {} \;

after all of the above do a clean install
aptitude install mysql-server mysql-client

check to see if mysql is running:
service mysql status

and you should get the response running

mysql start/running, process 3296

check with mysqladmin:

mysqladmin -u root -p status