Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    brew cleanup
    
  6. Remove files:

    sudo rm /usr/local/mysql
    sudo rm -rf /usr/local/var/mysql
    sudo rm -rf /usr/local/mysql*
    sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    sudo rm -rf /Library/StartupItems/MySQLCOM
    sudo rm -rf /Library/PreferencePanes/My*
    
  7. Unload previous MySQL Auto-Login:

    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
  8. Remove previous MySQL Configuration:

    subl /etc/hostconfig` 
    # Remove the line MYSQLCOM=-YES-
    
  9. Remove previous MySQL Preferences:

    rm -rf ~/Library/PreferencePanes/My*
    sudo rm -rf /Library/Receipts/mysql*
    sudo rm -rf /Library/Receipts/MySQL*
    sudo rm -rf /private/var/db/receipts/*mysql*
    
  10. Restart your computer just to ensure any MySQL processes are killed

  11. Try to run mysql, it shouldn't work

@thekeele

This comment has been minimized.

thekeele commented Nov 21, 2016

Swap 6 & 7? You're unloading a file that was deleted.

@jayantkeswani

This comment has been minimized.

jayantkeswani commented Jan 17, 2017

Thanks for the awesome walkthrough!

@leshek-pawlak

This comment has been minimized.

leshek-pawlak commented Jan 26, 2017

It helped me a lot. Thanks! 👍

@aryzhov

This comment has been minimized.

aryzhov commented Feb 5, 2017

I have MySQL 5.17.14. The daemon is installed in /Library/LaunchDaemons, not in /Library/LaunchAgents. I installed by downloading a DMG archive from dev.mysql.com.

@TibiaZ

This comment has been minimized.

TibiaZ commented Feb 14, 2017

Really useful! Thanks!

@decuyperjeremie

This comment has been minimized.

decuyperjeremie commented Apr 4, 2017

Really really useful, thanks a lot 👍

@Joseph1209

This comment has been minimized.

Joseph1209 commented Apr 5, 2017

pretty useful! thank u

@amithgc

This comment has been minimized.

amithgc commented Apr 15, 2017

Awesome, Thanks

@coolcat-310

This comment has been minimized.

coolcat-310 commented Apr 20, 2017

Thank you

@kevinzhang2012

This comment has been minimized.

kevinzhang2012 commented May 15, 2017

successfully uninstalled, thank you

@xiayank

This comment has been minimized.

xiayank commented Jun 9, 2017

Thx!!!

@ghost

This comment has been minimized.

ghost commented Jun 18, 2017

Thanks a lot! That's it.

@chandu6

This comment has been minimized.

chandu6 commented Jun 19, 2017

tnx man.

@davidmartinezfl

This comment has been minimized.

davidmartinezfl commented Jun 28, 2017

thanks!

@maxg203

This comment has been minimized.

maxg203 commented Aug 1, 2017

Really nice, works well. Thank you.

@jningtho

This comment has been minimized.

jningtho commented Aug 4, 2017

This is a brilliant walkthrough! Appreciate your time and making it so smooth. :)

@techlarry

This comment has been minimized.

techlarry commented Aug 10, 2017

Thanks a lot!

@yueyue21

This comment has been minimized.

yueyue21 commented Aug 12, 2017

wooow, this is good

@lonelykid

This comment has been minimized.

lonelykid commented Aug 25, 2017

I feel it's nonsense to do this. Why do we need such thing like Homebrew while it can't even uninstall a package completely for us?

@anto004

This comment has been minimized.

anto004 commented Aug 29, 2017

Thanks this worked for me.
I completely uninstalled mysql and installed Xampp mysql comes with it.

@seokany

This comment has been minimized.

seokany commented Sep 15, 2017

thnx!! , i 'm dont need uninstall my mac

@ashwinibaisutrave

This comment has been minimized.

ashwinibaisutrave commented Sep 22, 2017

Thank you ,really help full

@chandan29

This comment has been minimized.

chandan29 commented Sep 29, 2017

After trying about ten to fifteen things from different posts, this is the post that worked for me! Thanks a lot!

@anasebescen

This comment has been minimized.

anasebescen commented Oct 6, 2017

Thank you! Very help full!

@rochapablo

This comment has been minimized.

rochapablo commented Oct 19, 2017

I did all the process and worked then I installed again the mysql

$ brew install mysql
$ brew tap homebrew/services
$ brew services run mysql

And everything start work until today, where I tried to run my local website (as any other day) and I got:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

After that, every answer that I tried takes me to another error and so on. This is not the first time that happened and the only solution is re-install everything. So I was wondering if anyone have any idea why this could be happening. I don't want to run the entire process every time that mysql decide crash, but I want fix the problem or at least understand what is going on.

sequelize/cli#572

@nemalinde

This comment has been minimized.

nemalinde commented Oct 30, 2017

Thanks!

@caytekin

This comment has been minimized.

caytekin commented Oct 30, 2017

Great! Thanks.

@cAstraea

This comment has been minimized.

cAstraea commented Oct 31, 2017

still not working :((( it's really messed up now been trying for ages... think I need to factory reset my macbook pro and start anew ... been trying to install the imagick package but not mysql stopped working

@iredmedia

This comment has been minimized.

iredmedia commented Nov 24, 2017

Same here... mine's been butchered for almost a year.

@kumarankit1234

This comment has been minimized.

kumarankit1234 commented Nov 28, 2017

Restart computer is very important.

@diansheng

This comment has been minimized.

diansheng commented Dec 12, 2017

@rochapablo, i went through the same. Now after removing everything, i am going to install mysql version 5.6, and installing via the dmg file from community. https://dev.mysql.com/downloads/file/?id=463209. Then i can control via system preference panel. Hope i won't have that error anymore.

@lokatyre

This comment has been minimized.

lokatyre commented Jan 5, 2018

It helped! Thanks!

@sriharsha-sammeta

This comment has been minimized.

sriharsha-sammeta commented Jan 24, 2018

Thanks for saving the day ! 👍

@hubertperron

This comment has been minimized.

hubertperron commented Feb 7, 2018

Thanks, I was going mad trying to run MySQL on a old laptop that hasn't been updated to High Sierra. This fixed it.

@mugendiz

This comment has been minimized.

mugendiz commented Feb 10, 2018

Hey thanks, this is basically the only thing that worked

@raymonschouwenaar

This comment has been minimized.

raymonschouwenaar commented Mar 6, 2018

This saves us a lot of time 👍

@radub

This comment has been minimized.

radub commented Mar 27, 2018

$ brew remove mysql
Uninstalling /usr/local/Cellar/mysql/5.7.21... (323 files, 233.9MB)
mysql 5.7.20 1 is still installed.
Remove all versions with brew uninstall --force mysql.

@atuanpham

This comment has been minimized.

atuanpham commented Apr 7, 2018

Awesome! Thank you!

@MBegum02

This comment has been minimized.

MBegum02 commented May 7, 2018

Thanks alot!! Helped us alot!!

@dazjavier

This comment has been minimized.

dazjavier commented Jun 6, 2018

Thanks!

@ghost

This comment has been minimized.

ghost commented Jun 19, 2018

Thanks a million! These instructions allowed me to rollback from 8.0.11 to 5.7.

After 3 days of ripping my hair out, I can finally work again.

@algoth

This comment has been minimized.

algoth commented Jun 19, 2018

How did you install 5.7 after uninstalling? I am trying to rollback from 8.0.11 since yesterday but unable to do so.

@borgesbiel

This comment has been minimized.

borgesbiel commented Jun 29, 2018

worked, thanks!

@icehongssii

This comment has been minimized.

icehongssii commented Jul 24, 2018

rm: /Users/icehongssi/Library/LaunchAgents/homebrew.mxcl.mysql.plist: No such file or directory

..

@ricketybridge

This comment has been minimized.

ricketybridge commented Jul 25, 2018

subl results in command not found.

@mkompanets

This comment has been minimized.

mkompanets commented Jul 30, 2018

Had to also do this: sudo rm -rf /usr/local/bin/mysql

@redolivedev

This comment has been minimized.

redolivedev commented Jul 31, 2018

@algoth brew install mysql@5.7

@ryuchan00

This comment has been minimized.

ryuchan00 commented Aug 6, 2018

Thank you this gist.

@coreyderosa

This comment has been minimized.

coreyderosa commented Sep 19, 2018

I freaking love you!!

@pratyesh

This comment has been minimized.

pratyesh commented Oct 15, 2018

Thanks

@thatssushmit

This comment has been minimized.

thatssushmit commented Nov 3, 2018

I did all the process and worked then I installed again the mysql

$ brew install mysql
$ brew tap homebrew/services
$ brew services run mysql

And everything start work until today, where I tried to run my local website (as any other day) and I got:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

After that, every answer that I tried takes me to another error and so on. This is not the first time that happened and the only solution is re-install everything. So I was wondering if anyone have any idea why this could be happening. I don't want to run the entire process every time that mysql decide crash, but I want fix the problem or at least understand what is going on.

sequelize/cli#572

hey dear you can fix your problem by running
mysql.server start

@athomas-wtv

This comment has been minimized.

athomas-wtv commented Nov 15, 2018

In step 8, it's' supposed to read:
sudo /etc/hostconfig

for anyone having issues.
@ricketybridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment