Skip to content

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.

Copy link

commented Nov 21, 2016

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

@jayantkeswani

This comment has been minimized.

Copy link

commented Jan 17, 2017

Thanks for the awesome walkthrough!

@leshek-pawlak

This comment has been minimized.

Copy link

commented Jan 26, 2017

It helped me a lot. Thanks! 👍

@aryzhov

This comment has been minimized.

Copy link

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.

Copy link

commented Feb 14, 2017

Really useful! Thanks!

@decuyperjeremie

This comment has been minimized.

Copy link

commented Apr 4, 2017

Really really useful, thanks a lot 👍

@Joseph1209

This comment has been minimized.

Copy link

commented Apr 5, 2017

pretty useful! thank u

@amithgc

This comment has been minimized.

Copy link

commented Apr 15, 2017

Awesome, Thanks

@coolcat-310

This comment has been minimized.

Copy link

commented Apr 20, 2017

Thank you

@kevinzhang2012

This comment has been minimized.

Copy link

commented May 15, 2017

successfully uninstalled, thank you

@xiayank

This comment has been minimized.

Copy link

commented Jun 9, 2017

Thx!!!

@ghost

This comment has been minimized.

Copy link

commented Jun 18, 2017

Thanks a lot! That's it.

@chandu6

This comment has been minimized.

Copy link

commented Jun 19, 2017

tnx man.

@davidmartinezfl

This comment has been minimized.

Copy link

commented Jun 28, 2017

thanks!

@maxg203

This comment has been minimized.

Copy link

commented Aug 1, 2017

Really nice, works well. Thank you.

@jningtho

This comment has been minimized.

Copy link

commented Aug 4, 2017

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

@techlarry

This comment has been minimized.

Copy link

commented Aug 10, 2017

Thanks a lot!

@yueyue21

This comment has been minimized.

Copy link

commented Aug 12, 2017

wooow, this is good

@lonelykid

This comment has been minimized.

Copy link

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.

Copy link

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.

Copy link

commented Sep 15, 2017

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

@ashwinibaisutrave

This comment has been minimized.

Copy link

commented Sep 22, 2017

Thank you ,really help full

@chandan29

This comment has been minimized.

Copy link

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.

Copy link

commented Oct 6, 2017

Thank you! Very help full!

@rochapablo

This comment has been minimized.

Copy link

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.

Copy link

commented Oct 30, 2017

Thanks!

@caytekin

This comment has been minimized.

Copy link

commented Oct 30, 2017

Great! Thanks.

@cAstraea

This comment has been minimized.

Copy link

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.

Copy link

commented Nov 24, 2017

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

@kumarankit1234

This comment has been minimized.

Copy link

commented Nov 28, 2017

Restart computer is very important.

@diansheng

This comment has been minimized.

Copy link

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.

Copy link

commented Jan 5, 2018

It helped! Thanks!

@sriharsha-sammeta

This comment has been minimized.

Copy link

commented Jan 24, 2018

Thanks for saving the day ! 👍

@hubertperron

This comment has been minimized.

Copy link

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.

Copy link

commented Feb 10, 2018

Hey thanks, this is basically the only thing that worked

@raymonschouwenaar

This comment has been minimized.

Copy link

commented Mar 6, 2018

This saves us a lot of time 👍

@radub

This comment has been minimized.

Copy link

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.

Copy link

commented Apr 7, 2018

Awesome! Thank you!

@MBegum02

This comment has been minimized.

Copy link

commented May 7, 2018

Thanks alot!! Helped us alot!!

@dazjavier

This comment has been minimized.

Copy link

commented Jun 6, 2018

Thanks!

@ghost

This comment has been minimized.

Copy link

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.

Copy link

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.

@gabrielbidula

This comment has been minimized.

Copy link

commented Jun 29, 2018

worked, thanks!

@icehongssii

This comment has been minimized.

Copy link

commented Jul 24, 2018

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

..

@ricketybridge

This comment has been minimized.

Copy link

commented Jul 25, 2018

subl results in command not found.

@mkompanets

This comment has been minimized.

Copy link

commented Jul 30, 2018

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

@redolivedev

This comment has been minimized.

Copy link

commented Jul 31, 2018

@algoth brew install mysql@5.7

@ryuchan00

This comment has been minimized.

Copy link

commented Aug 6, 2018

Thank you this gist.

@coreyderosa

This comment has been minimized.

Copy link

commented Sep 19, 2018

I freaking love you!!

@pratyesh

This comment has been minimized.

Copy link

commented Oct 15, 2018

Thanks

@thatssushmit

This comment has been minimized.

Copy link

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.

Copy link

commented Nov 15, 2018

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

for anyone having issues.
@ricketybridge

@lsantamaria

This comment has been minimized.

Copy link

commented Dec 22, 2018

Thanks!

@peanutgao

This comment has been minimized.

Copy link

commented Jan 3, 2019

Thanks

@ianrandmckenzie

This comment has been minimized.

Copy link

commented Jan 10, 2019

For me the line:
sudo rm -rf /usr/local/var/mysql
Was the main fix. I reinstalled mysql@5.7 after removing that folder and everything worked. The super weird thing, however, is it took me several attempts at deleting that file to get things to finally work. I have no idea what I did differently the final time to get it to work, but hopefully this message points someone in the right direction.

Also: I completely removed MAMP from my machine, so that might have helped somewhere along the way as well. At this stage of my development skill, I no longer need MAMP under my toolbelt.

@Hanyuxiaoorz

This comment has been minimized.

Copy link

commented Jan 26, 2019

It is useful for installed by homebrew.

@vaimeo

This comment has been minimized.

Copy link

commented Jan 29, 2019

Perfect i just love the people like you to explain simple words

@liz282907

This comment has been minimized.

Copy link

commented Feb 12, 2019

thanks!

@thehackercat

This comment has been minimized.

Copy link

commented Feb 14, 2019

good

@joaovcarvalho

This comment has been minimized.

Copy link

commented Mar 9, 2019

Great! Thanks!

@marcusflat

This comment has been minimized.

Copy link

commented Mar 25, 2019

Great !!!!

Thanks

@AskFeeds

This comment has been minimized.

Copy link

commented Mar 27, 2019

I want to use a different AMP stack on my mac. I deactivated Apache and PHP and uninstalled MySQL. Deactivating Apache server is easy with command line. But to uninstall MySQL is a little bit more complex. Thanks for sharing this great tip.

@spearkkk

This comment has been minimized.

Copy link

commented Apr 19, 2019

Thank you !!
You saved my time!!

@tnorthcutt

This comment has been minimized.

Copy link

commented Apr 24, 2019

This was very helpful. I also had to do:

rm /usr/local/etc/my.cnf

Something I had done previously had resulted in a my.cnf file that prevented MySQL from working (I was getting the dreaded ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) error).

@annstringer

This comment has been minimized.

Copy link

commented Apr 29, 2019

This helped. I also had the ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) and also had to remove rm /usr/local/etc/my.cnf.

Thanks.

@genorchiomento

This comment has been minimized.

Copy link

commented May 7, 2019

Thanks bro! This helped

@HimanshuLuthra

This comment has been minimized.

Copy link

commented May 18, 2019

Do reboot else it wont work

@brendanfalkowski

This comment has been minimized.

Copy link

commented May 30, 2019

This helped immensely a couple months ago, and I finally went back to document the fix in my field manuals for Homebrew and Valet Plus:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.