Ubuntu 10.x completely remove and clean MySQL installation
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





































































April 8th, 2011 at 20:49
Thanks a ton! Your post saved me, i was struggling from hours to do a fresh install.
April 14th, 2011 at 23:54
Thanks, have been messing around with this for days. Worked a treat
November 30th, 2011 at 20:11
My pleasure, I struggled for HOURS to re-install MySQL. so I thought I’d write it down.
February 2nd, 2012 at 20:17
Thanks a lot dude !
February 24th, 2012 at 09:04
Thanks for this. I’ve been locked out of mysql for days now. This really helped.
Cheers.
March 12th, 2012 at 04:24
absolute legend. been wresting with a lamp mysql installation for a day now, wish I had just done this at the start!
March 31st, 2012 at 12:38
Good resume! I had only one issue because of typing without thinking. I have a dual boot with a WAMP under Vista on the other SO, so when rm -rf inside the find… it looked into my Media/Data disk… well… I will have to reinstall WAMP xD
April 1st, 2012 at 19:41
Thanks! This was just the ticket.
April 11th, 2012 at 04:20
You sir, are a life saver.
Thanks.
April 12th, 2012 at 18:44
Works perfectly!
Kubuntu 11.10
Thanks a lot!
April 20th, 2012 at 09:39
And if you want to get rid of the database files themselves, you may need to delete /usr/local/mysql or /var/lib/mysql or somewhere else depending on your distro.
April 26th, 2012 at 00:02
Great fix, man. I originally used aptitude to unistall mysql. However, I ran into some trouble. It didn’t seem to uninstall everything..but, apt-get did the trick. I’m new to Linux, so it was probably something I did
May 2nd, 2012 at 07:48
Thanks a lot! 2 hours I fight with mysql fixing after ubuntu upgrade to 12.04.
And you post help me to win.