Ubuntu 10.x completely remove and clean MySQL installation

Posted by admin on January 08, 2011  /   Posted in mysql, Ubuntu

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

About admin

iDoThisStuffThatSpins()

27 Comments

  1. midas 2011/04/08 20:49

    Thanks a ton! Your post saved me, i was struggling from hours to do a fresh install.

  2. Scott Waller 2011/04/14 23:54

    Thanks, have been messing around with this for days. Worked a treat

  3. admin 2011/11/30 20:11

    My pleasure, I struggled for HOURS to re-install MySQL. so I thought I’d write it down.

  4. Elvynia 2012/02/02 20:17

    Thanks a lot dude !

  5. Mike 2012/02/24 09:04

    Thanks for this. I’ve been locked out of mysql for days now. This really helped.

    Cheers.

  6. PMC 2012/03/12 04:24

    absolute legend. been wresting with a lamp mysql installation for a day now, wish I had just done this at the start!

  7. Dani Ramírez 2012/03/31 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

  8. Paladin 2012/04/01 19:41

    Thanks! This was just the ticket.

  9. Danny Coulombe 2012/04/11 04:20

    You sir, are a life saver.

    Thanks.

  10. kiesel 2012/04/12 18:44

    Works perfectly!
    Kubuntu 11.10
    Thanks a lot!

  11. dougalg 2012/04/20 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.

  12. Nate 2012/04/26 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

  13. Solid 2012/05/02 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.

  14. Pingback: Installing mySQL on AWS EC2 Ubuntu Machine through SSH « Application & Program Tips « Electronic Services

  15. James Wolfe 2012/05/10 02:15

    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!!

  16. ishipaco 2012/06/10 23:23

    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.

  17. Axel Roland 2012/06/26 15:41

    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.

  18. rezamarefaty 2012/06/29 07:39

    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 .

  19. Marcin 2012/07/06 10:41

    Thanks a lot, you saved me a lots of hours :)

  20. Pingback: 007/usr/bin/mysqladmin: connect to server at ‘localhost’ failed => re-installez mysql

  21. Sajal 2012/08/09 07:15

    Thanks a lot. You helped me alot. You are a champ…thanx again…:)

  22. Fabiano 2012/09/13 20:21

    thanks a LOT man!!!!!!!

  23. Pingback: Dificulty during installation of MySQL Server 5.1 video

  24. Pingback: Dificulty during installation of MySQL Server 5.1 closed | Code and Programming

  25. Pingback: MySQL and SQL « seethingtension

  26. Pingback: How completer remove mysql-server from debian etch

  27. Pingback: Ubuntu 10.x completely remove and clean MySQL installation | StuffThatSpins.com | Patric Lougheed

Post a Comment

Your email address will not be published. Required fields are marked *

*

 

^ Back to Top