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
Thanks a ton! Your post saved me, i was struggling from hours to do a fresh install.
[Translate]
Thanks, have been messing around with this for days. Worked a treat
[Translate]
My pleasure, I struggled for HOURS to re-install MySQL. so I thought I’d write it down.
[Translate]
Thanks a lot dude !
[Translate]
Thanks for this. I’ve been locked out of mysql for days now. This really helped.
Cheers.
[Translate]
absolute legend. been wresting with a lamp mysql installation for a day now, wish I had just done this at the start!
[Translate]
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
[Translate]
Thanks! This was just the ticket.
[Translate]
You sir, are a life saver.
Thanks.
[Translate]
Works perfectly!
Kubuntu 11.10
Thanks a lot!
[Translate]
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.
[Translate]
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
[Translate]
Thanks a lot! 2 hours I fight with mysql fixing after ubuntu upgrade to 12.04.
And you post help me to win.
[Translate]
Pingback: Installing mySQL on AWS EC2 Ubuntu Machine through SSH « Application & Program Tips « Electronic Services
It doesn’t work when the mysql.sock is missing!! tried to uninstall because mysql.sock was missing, and i couldn’t porperly uninstall mysql!!
[Translate]
After literally days of searching the web for a fix to a suddenly non-functioning MySQL installation, I found your fix. Excellent! It worked. I’m back in business. I won’t even attempt to list all the other things I tried first. Muchas gracias.
[Translate]
I recommend NOT to use the
find / -iname ‘mysql*’ -exec rm -rf {} \;
- it will delete ALL files starting with the name “mysql” on your system – no matter if they have anything to do with the MySQL package or not.
For example: If you have a file like:
mysql-my-very-important-thesis.docx
it will be deleted.
[Translate]
Hi
Thanks alot man , i was try to work on Yii , one of the PHP frameworks and long story short my mysql try to mess with me until i find your article and it work great .
[Translate]
Thanks a lot, you saved me a lots of hours
[Translate]
Pingback: 007/usr/bin/mysqladmin: connect to server at ‘localhost’ failed => re-installez mysql
Thanks a lot. You helped me alot. You are a champ…thanx again…:)
[Translate]
thanks a LOT man!!!!!!!
[Translate]
Pingback: Dificulty during installation of MySQL Server 5.1 video
Pingback: Dificulty during installation of MySQL Server 5.1 closed | Code and Programming
Pingback: MySQL and SQL « seethingtension
Pingback: How completer remove mysql-server from debian etch
Pingback: Ubuntu 10.x completely remove and clean MySQL installation | StuffThatSpins.com | Patric Lougheed